Ng-使用ng-repeat进行检查,而不使用angularjs中的for循环

时间:2018-02-01 21:15:00

标签: angularjs angularjs-ng-checked

任何人都可以帮助找出ng-checked

$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}]

如果我使用循环,这项工作。但我不想使用循环。有没有其他方法可以解决。我试过ng-change,ng-click但仍然没有工作。

1 个答案:

答案 0 :(得分:0)

我不确定您的问题是否与选择所有功能无效或对阵列进行ng-repeat有关。

我想你希望你的对象变成这样: '.

如果是这种情况,请检查this plunker以获得解决方案。