A simple program to ask the user to give a number and then the program will compute and display the Fibonacci series using the controller in AngularJS.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website, kindly contact me also at my email address also. Thank you.
My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com
My mobile number here in the Philippines is 09173084360.
Program Listing
<!-- index.htm
Author : Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
Date : August 13, 2021 9:14 AM Friday
Place : Bacolod City, Negros Occidental
Websites : www.jakerpomperada.com and www.jakerpomperada.blogspot.com
Email : jakerpomperada@gmail.com
-->
<html>
<head>
<title>Fibonacci Series Using Controllers in AngularJS</title>
<script type="text/javascript" src="angular.min.js"></script>
<script>
var myApp=angular.module("myModule",[]);
myApp.controller("Fibonacci_Series",function($scope) {
$scope.Fibonacci_Generate=function()
{
$scope.result = "Fibonacci Series"
var arr = [];
let n1 = 0, n2 = 1, nextTerm;
for (let i = 1; i <= $scope.a; i++) {
arr.push(n1);
document.getElementById("outputDiv").innerHTML = arr;
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
}
$scope.Clear_All=function()
{
$scope.a = "";
document.getElementById("outputDiv").innerHTML = "";
$scope.result = "";
}
});
</script>
</head>
<style>
body {
font-family: arial;
font-size: 25px;
font-weight: bold;
}
</style>
<body ng-app="myModule" ng-controller="Fibonacci_Series">
<h3>Fibonacci Series Using Controllers in AngularJS
</h3>
<div>
<table border="0">
<tr>
<td>
Give a Positive Number
</td>
<td>
<input type="number" ng-model="a"/>
</td>
<tr>
<tr>
<td colspan="10">
<br>
<input type="button" ng-click="Fibonacci_Generate();"
value="Generate Fibonacci Series"/>
<input type="button" ng-click="Clear_All();"
value="Clear"/>
</td>
</tr>
</table>
</div>
<p> {{result}} </p>
<textarea id="outputDiv" name="outputDiv" rows="4" cols="50">
</textarea>
</body>
</html>
No comments:
Post a Comment