Binding 为什么嵌套范围内的模型获胜';更改值时是否无法更新?
AngularJs资料来源:Binding 为什么嵌套范围内的模型获胜';更改值时是否无法更新?,binding,nested,angularjs,Binding,Nested,Angularjs,AngularJs资料来源: <html ng-app> <body ng-controller="Controller"> <div ng-init="numbers=[11,22,33]"> <div ng-repeat="n in numbers"> <input type="text" ng-model="n"/> [{{n}}] </div> <
<html ng-app>
<body ng-controller="Controller">
<div ng-init="numbers=[11,22,33]">
<div ng-repeat="n in numbers">
<input type="text" ng-model="n"/> [{{n}}]
</div>
</div>
<script>
function Controller($scope) {}
</script>
</body>
</html>
[{{n}}]
函数控制器($scope){}
当我更改输入值时,右侧的文本不会更新。哪里错了
现场演示如下:
您可以更改输入中的值,然后查看。尝试使用对象数组:
function Controller($scope) {
$scope.numbers = [{value: 11 }, {value: 22 }, {value: 33 }];
}
<html ng-app>
<body ng-controller="Controller">
<div>
<div ng-repeat="n in numbers">
<input type="text" ng-model="n.value"/> [{{n.value}}]
</div>
</div>
</body>
</html>
功能控制器($scope){
$scope.numbers=[{value:11},{value:22},{value:33}];
}
[{{n.value}}]
看