<!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