-1

任何人都可以帮助弄清楚 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}]

如果我使用 for 循环,这项工作。但我不想使用循环。有没有其他方法可以帮助任何人。我尝试使用 ng-change、ng-click 但仍然没有工作。

4

1 回答 1

0

我不确定您的问题是否在于选择所有功能不起作用或阵列上的 ng-repeat。

我猜你希望你的对象变成这样: [{ID:23,NAME:zz, checked: true},{ID:65,NAME:tt, checked: true},etc]

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

于 2018-02-01T22:05:15.263 回答