over 10 years ago
This Script will helpful to make a simple 'addition' 'subtraction' 'multiplication' 'division' calculator with the help of Angular JS.
- <!DOCTYPE html >
- <html>
- <head>
- <title>Angulor Calculator</title>
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
- <link rel="stylesheet" type="text/css" href="css/style.css" media="all">
- </head>
- <body>
- <div ng-app>
- <fieldset>
- <h2>Calculator</h2>
- <dl>
- <dt>First No :</dt>
- <dd><input type="text" ng-model="first" /></dd>
- <dt>Second No :</dt>
- <dd><input type="text" ng-model="second" /></dd>
- <div class="clr"></div>
- </dl>
- <div class="operations">
- <button ng-click="total = first -- second">Add</button> //For addition
- <button ng-click="total = first - second">Sub</button> //For subtraction
- <button ng-click="total = first * second">Mul</button> //For multiplication
- <button ng-click="total = first / second">Div</button> //For division
- </div>
- <label class="result">Result: {{total}}</label>
- </fieldset>
- </div>
- </body>
- </html>
<!DOCTYPE html > <html> <head> <title>Angulor Calculator</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css" media="all"> </head> <body> <div ng-app> <fieldset> <h2>Calculator</h2> <dl> <dt>First No :</dt> <dd><input type="text" ng-model="first" /></dd> <dt>Second No :</dt> <dd><input type="text" ng-model="second" /></dd> <div class="clr"></div> </dl> <div class="operations"> <button ng-click="total = first -- second">Add</button> //For addition <button ng-click="total = first - second">Sub</button> //For subtraction <button ng-click="total = first * second">Mul</button> //For multiplication <button ng-click="total = first / second">Div</button> //For division </div> <label class="result">Result: {{total}}</label> </fieldset> </div> </body> </html>
I hope this script is helpful for you to understand a simple angular JS program.
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)