angularjs 手动加载
利用ng-app可以完成自动加载,如果不利用ng-app。那么使用bootstrarp实现手动加载模块
<html> <head> <script src="angular.js"></script> <script> // 创建moudle1 var rootMoudle = angular.module('moudle1', []); rootMoudle.controller("controller1",function($scope){$scope.name="aty"}); // 创建moudle2 var m2 = angular.module('moudle2', []); m2.controller("controller2",function($scope){$scope.name="aty"}); // 页面加载完成后,再加载模块 angular.element(document).ready(function() { angular.bootstrap(document.getElementById("div1"),["moudle1"]); angular.bootstrap(document.getElementById("div2"),["moudle2"]); }); </script> <head> <body> <div id="div1" ng-controller="controller1">div1:{{name}}</div> <div id="div2" ng-controller="controller2">div2:{{name}}</div> </body> </html>