Always want to learn angularjs, but do not know what the benefits of Angularjs used in the page, today I have a humble understanding, record down.
<Scriptsrc= "Http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></Script> <DivNg-controller= "Mycalc">Unit Price:<spanNg-model= "Number1">5</span> <BR/>Quantity:<inputtype= "Number"min= "2"Max= "Ten"Ng-model= "Number2"Required></TD> <HR> <b>Total:</b>{{Number1 * number2 | currency}}</Div>
Write a simple calculator like this. As for the usefulness, I only think of our front-end in the writing of the shopping cart, the need to calculate the amount and unit price of the total price, and then each unit price needs to calculate the sum, with this is particularly convenient.
<script> function Mycalc ($scope) { $scope. number1 = 5; $scope. number2 = 5.60; } </script>
Add the above code, NUMBER1 represents the unit price, number2 represents the quantity, in total in real-time to get the full price. Don't forget to add
The overall code is
<! DOCTYPE html>
The first calculator written with Angularjs