The first calculator written with Angularjs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.