Cordova学习笔记 factory及模块动态加载及模块依赖
<!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>test</title><scriptsrc="js/angular.js"></script><scripttype="application/javascript">(function(angular){'usestrict';angular.module('myApp2',[]).factory('plusMath',function(){varfactory={};factory.plus=function(a,b){returna+b;}returnfactory;});})(window.angular);//副模块依赖主模块为主模块提供服务(function(angular){'usestrict';angular.module('myApp',['myApp2']).controller('firstController',functionfirstController($scope,plusMath){$scope.name='test';$scope.result=plusMath.plus(11,32);});})(window.angular);//主模块window.onload=function(){varmyAppdiv=document.getElementById('myApp22');angular.bootstrap(myAppdiv,['myApp'])//动态的绑定主mudule的html作用范围}</script></head><body><divid="myApp22"><divng-controller="firstController"><divng-bind="name"></div><div>11+32=</div><divng-bind="result"></div></div></div></body></html>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。