<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script src="angular.js"></script>
</head>
<body ng-app="todo">
<div ng-controller="ctrl1">
<input type="text" ng-model="msg"/>
<div>{{msg}}</div>
<div ng-controller="ctrl2">
<input type="text" ng-model="msg"/>
<div ng-bind="msg"></div>
</div>
</div>
</body>
<script>
angular.module('todo',[]).controller('ctrl1',function($scope){
$scope.msg="a";//1
}).controller('ctrl2',function($scope){
$scope.msg="b";//2
})
</script>
</html>
若1處不寫,則正常;
若2處不寫,則第一次若填寫外層input,內層input和div也會被控制,填寫了內層input就能擺脫控制;
若1、2處都不寫,同第2處不寫;
我的想法是:ng-model的變量開始不會被添加到作用域內,只有執行過一次纔會被添加。