gpt4 book ai didi

javascript - 选中所有复选框并将所有更新状态作为对象发送 [Angular Js]

转载 作者:行者123 更新时间:2023-12-03 06:50:02 24 4
gpt4 key购买 nike

我用过这个

<div class="col-sm-12">
<form>
<input type="checkbox" onclick="for(c in document.getElementsByName('rfile')) document.getElementsByName('rfile').item(c).checked = this.checked" >Check All </button>

<table>
<thead>
<tr role="row">
<th>Student ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in searchResults">
<td ><a href="#/Attendance/edit/{{result.id}}">{{result.studentId}}</a>
</td>
<td ><input type="checkbox" name="rfile" ng-model="result.status" /> {{result.status}}</td>
</tr>
</tbody>
</table>
<div>
<button ng-click="save()">Save</button>

</div>
</div>

</div>

</form>
</div>

它完美地检查了所有复选框,但没有更新状态。

我应该做什么..当我单击单独的复选框进行更新时,它工作正常。

TIA我是初学者..所以请不要投反对票。

最佳答案

您必须使用 ng-click 或 ng-change 来操作范围数据并将所有结果状态设置为 true(或 false)。

这里有一个 plunker 来说明它: https://plnkr.co/edit/YW6opuPTgtXXg08OzbM6?p=preview

查看您的复选框以选中所有内容

<input type="checkbox" ng-click="onCheckAll()" ng-model="checkAll">Check All

关于javascript - 选中所有复选框并将所有更新状态作为对象发送 [Angular Js],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37546185/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com