谁能帮忙弄清楚ng-check
$scope.ABC=[{ID:23,NAME:zz},{ID:65,NAME:tt},{},{}]
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th></th>
<th><input type="checkbox" ng-model="AllChecked" /></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in ABC">
<td>{{x.ID}}</td>
<td>{{x.NAME}}</td>
<td><input type="checkbox" ng-model="x.selection" ng-checked="AllChecked" required /></td>
</tr>
</tbody>
Output i want:-
[{ID:x.23,Select:true},{ID:x.65,Select:true},{ID:x.ID,Select:true}]
如果我使用 for 循环,这有效。但我不想使用循环。有没有其他方法可以嘘。我尝试使用ng-change,ng-click,但仍然不起作用。
我不确定您的问题是否在于选择所有功能不起作用或在您的数组上重复 ng。
我猜你希望你的对象变成这样:
[{ID:23,NAME:zz, checked: true},{ID:65,NAME:tt, checked: true},etc]
如果是这种情况,请检查此 plunker 以获取解决方案。