【问题标题】:Ng-Checked with ng-repeat without using for loop in angularjs使用 ng-repeat 进行 Ng-Checked 而不在 angularjs 中使用 for 循环
【发布时间】:2018-02-01 21:15:00
【问题描述】:

任何人都可以帮助弄清楚 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 但仍然没有工作。

【问题讨论】:

  • 您的问题是“全选”功能还是 ng-repeat 无法正常工作?

标签: angularjs angularjs-ng-checked


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 2016-09-06
    • 2023-03-20
    • 1970-01-01
    相关资源
    最近更新 更多