Angularjs Purchase Amount Instance operation

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLNg-app><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title><Scriptsrc= "Angular.min.js"></Script><Script>    functionAaa ($scope, $timeout) {$scope. iphone={money: the, Num:1, Fre:Ten        }; $scope. Sum= function(){            return$scope. Iphone.money*$scope. Iphone.num;                }; /*$scope. $watch (' Iphone.money ', function (newval,oldval) {//iphone.money here means that the input box for listening is Money Console.log (NEWV    AL);    The computed value, the value of the Console.log (Oldval) that is being monitored; The value before the calculation, the value of the},true being monitored);*/$scope. $watch ($scope. Sum,function(newval,oldval) {//$watch Listening means, you can also listen to functions            //Console.log (newval);            //Console.log (oldval);$scope. Iphone.fre=newval>=  - ? 0 : Ten;    }); }</Script></Head><Body>    <DivNg-controller= "Aaa">        <P>Price:<inputtype= "text"Ng-model= "Iphone.money"></P>        <P>Number:<inputtype= "text"Ng-model= "Iphone.num"></P>        <P>Cost:<span>{{sum () | currency: ' ¥ '}}</span></P>    <!--currency This is a filter, currency formatting method, default is dollar sign -        <P>Shipping:<span>{{Iphone.fre | currency: ' ¥ '}}</span></P>        <P>Total:<span>{{sum () + iphone.fre | Currency: ' ¥ '}}</span></P>    </Div></Body></HTML>

Angularjs Purchase Amount Instance operation

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.