这样写新版本可以正常使用
<body ng-app="myApp">
<div ng-controller="CommonController">
<div ng-controller="Controller1">
<p>{{greeting.text}},angular</p>
<button ng-click="test1()">test1</button>
</div>
<div ng-controller="Controller2">
<p>{{greeting.text}},angular</p>
<button ng-click="test2()">test2</button>
</div>
<button ng-click="commonFn()">通用</button>
</div>
</body>
--------------------------------------------------------------------------
angular.module("myApp",[]).controller("CommonController",['$scope',function($scope){
$scope.commonFn=function (){
alert("这是通用功能")
}
}]).controller("Controller1",['$scope',function($scope){
$scope.greeting={
text:"hello1"
}
$scope.test1=function (){
alert("test1")
}
}]).controller("Controller2",['$scope',function($scope){
$scope.greeting={
text:"hello2"
}
$scope.test2=function (){
alert("test2")
}
}]);