1. 多个module,需要调用angular.bootstrap(document.documentElement, ['myApp','myApp1']);
<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8" />
<title>??</title>
<!--<script type="text/javascript" src="http://s.zys.me/js/jq/jquery.js"></script>-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
</head>
<body>
<div ng-app='myApp'>
<div ng-controller="MyController">
<input ng-model="expr" type="text" placeholder = "Enter an expression"/>
<h2>{{parsedValue}}</h2>
</div>
</div>
<div ng-app='myApp1'>
<div ng-controller="MyController">
<input ng-model="expr" type="text" placeholder = "Enter an expression"/>
<h2>{{parsedValue}}</h2>
</div>
</div>
<script type="text/javascript">
angular.module('myApp', []).controller('MyController',function($scope,$parse){
$scope.$watch('expr', function(newVal, oldVal, scope){
if(newVal !=oldVal){
var parseFun = $parse(newVal);
$scope.parsedValue = parseFun(scope);
}
})
});
angular.module('myApp1', []).controller('MyController',function($scope,$parse){
$scope.$watch('expr', function(newVal, oldVal, scope){
if(newVal !=oldVal){
var parseFun = $parse(newVal);
$scope.parsedValue = parseFun(scope);
}
})
});
angular.bootstrap(document.documentElement, ['myApp','myApp1']);
</script>
</body>
</html>