<div ng-controller="OparentController as pCtrl">
<p>直接访问父控制器的值:{{user}}</p>
<div ng-controller="OchildController as cCtrl">
<p>嵌套如何访问。。父控制器的值:失败:<input ng-model="pUser"/>成功:<input ng-model="obj2.pUser"/></p>
<p>子控制器的值:{{user}}</p>
<button ng-click="modiV()">clk:子控制器内修改父控制器内(作用域)的值</div>
</div>
</div>
<script>
var a10086=angular.module('a10086',[]);
a10086.controller('OparentController',function($scope){
$scope.user='parent_李四';
$scope.msg={a:'parent_李四',b:4,c:[1,34]};
}).controller('OchildController',function($scope){
$scope.user='child_张三';
$scope.pUser=$scope.msg.a;
$scope.obj2={
pUser:$scope.msg.a
};
$scope.modiV=function(){
$scope.msg.a="parent_李四 is modify";
$scope.obj2.pUser="parent_李四 is modify---obj";
console.log('子控制没有msg,才顺着原型链修改了:',$scope.msg, $scope.pUser);
}
});
</script>