Cordova学习笔记 中controller的使用及controller as的使用
<!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(){this.firstNum=1;this.secondNum=1;this.doSum111=function(){returnthis.firstNum+this.secondNum;};});})(window.angular);</script></head><body><divng-app="myApp"><divng-controller="firstControllerasfc"><!--ControllerAs语法,简单说就是可以在Controller中使用this来替代$scopefc就相当于this了--><inputtype="number"name="firstNum"ng-model="fc.firstNum"required/>+<inputtype="number"name="secondNum"ng-model="fc.secondNum"required/>={{fc.doSum111()}}</div></div></body></html>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。