【发布时间】:2016-02-18 10:34:25
【问题描述】:
我有这样的范围对象:
myObject: {
A: '',
B: '',
otherValues: {
0: {
myValue: '',
status: ''
}
1: {
myValue: '',
status: ''
}
}
}
我有复选框列表:
<tr ng-repeat="(key, value) in myArray">
<td><input name="{{value.myValue}}" type="checkbox"
ng-model="myObject.otherValues[$index].status"
ng-click="setFunction(value.myValue,$index)" />
</tr>
状态由 ng-model (true,false) 设置。我想使用 setFunction 设置 myValue。 在我的控制器中,我有这个功能:
function setFunction (value,index) {
$scope.myObject.otherValues[index].myValue= value;
}
但是会产生控制台错误:TypeError: Cannot read property '0' of undefined 我该如何解决?
【问题讨论】:
-
你能给我们一些小提琴或小玩意儿吗?
-
我认为
otherValues应该是一个数组
标签: angularjs