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