<!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的变量开始不会被添加到作用域内,只有执行过一次才会被添加。