Cordova学习笔记 $scope的$watch及$timeout的使用示例
<!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>test</title><scriptsrc="js/angular.js"></script><scripttype="application/javascript">(function(angular){'usestrict';angular.module('myApp',[]).controller('firstController',functionfirstController($scope,$timeout){$scope.firstNum=1;$scope.secondNum=1;$scope.doMySum=function(){varfn=angular.isNumber($scope.firstNum)?$scope.firstNum:0;varsn=angular.isNumber($scope.secondNum)?$scope.secondNum:0;returnfn+sn;}$timeout(function(){$scope.firstNum=10;},2000);$scope.$watch('doMySum()',function(newValue,oldValue){if(newValue==100){alert('ok');}});});})(window.angular);</script></head><body><divng-app="myApp"><divng-controller="firstController"><inputtype="number"name="firstNum"ng-model="firstNum"required/>+<inputtype="number"name="secondNum"ng-model="secondNum"required/>={{doMySum()}}</div></div></body></html>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。