目前,我在AngularJS的每一行中都有一个带有复选框的表;
<table class="table table-hover data-table sort display">
<thead>
<tr>
<th>Name</th>
<th>Location</th>
<th>Checkbox Alert</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in filteredList | orderBy:columnToOrder:reverse">
<td>{{item.name}}</td>
<td>{{item.location}}</td>
<td><input type="checkbox" ng-model="selected" ng-change="display(selected, item)"></td>
</tr>
</tbody>
</table>
我有一个布尔变量{{item.checkbox_status}}
,它反映该复选框是应选中还是未选中。我应如何将此变量放入上面的表html代码中以获取复选框以反映检查状态?还是我需要在控制器上工作?
ng-model是您的答案。
即:
<input type="checkbox" ng-model="item.checkbox_status" ng-click="alert_display()" ng-true-value="true" ng-false-value="false" />
参考:https : //docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D
希望我能帮上忙。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句