我假设范围问题是此示例中的输入可以修改它旁边的值但不能修改其他值的原因。如果是这种情况,我如何将模型连接到正确的范围?如果这不是范围问题,我做错了什么?
<html ng-app>
<head>
<script type="text/javascript" src="angular-1.0.1.min.js"></script>
<script type="text/javascript">
function ExampleCtrl($scope) {
$scope.list = [
{ name: "a" },
{ name: "b" },
];
$scope.value = 5;
}
</script>
</head>
<body ng-controller="ExampleCtrl">
<ul ng-repeat="item in list">
<li>{{ item.name }}
<ng-switch on="item.name">
<span ng-switch-when="b">
<input type="number" ng-model="value" />
{{ value }}
</span>
</ng-switch>
</li>
</ul>
value is {{ value }}
</body>
</html>