<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ng-app指令,angular找到第一个ng-app就不会再找了,在一个页面中只使用一个ng-app.</title>
</head>
<body ng-app="myApp">
<input type="button" ng-controller="App1Controller" ng-click="do1()" value="按钮1" />
<input type="button" ng-controller="App2Controller" ng-click="do2()" value="按钮2">
<script src="bower_components/angular/angular.js"></script>
<script>
var myApp1 = angular.module('myApp1', []);
myApp1.controller('App1Controller', ['$scope', function($scope){
$scope.do1 = function(){
console.log(11111);
};
}]);
var myApp2 = angular.module('myApp2', []);
myApp2.controller('App2Controller', ['$scope', function($scope){
$scope.do2 = function(){
console.log(22222);
};
}]);
/**
* myApp Mod'myApp1','myApp2'ul;
*
* Description
*/
angular.module('myApp', ['myApp1','myApp2']);
</script>
</body>
</html>
就是用一个大的模块将两个小模块包起来