我是新的AngularJS。我試圖用單個複選框選中所有複選框,並執行checkboxClick
方法。因爲我們將值設定爲範圍。怎麼做?選擇angularJS中的所有複選框
<input class="check-box" data-val="true" type="checkbox">Select All </input>
<table class="table table-bordered">
<tr>
<th></th>
<th>Printed</th>
<th>First Name</th>
<th>Last Name</th>
<th>Company</th>
<th>City</th>
<th>Country</th>
</tr>
<tr ng-repeat="item in items">
<td>
<input class="check-box" data-val="true" type="checkbox" ng-model="item.selected" ng-click="checkboxClick($event, item)">
</td>
<td>
{{item.printed}}
</td>
....
....
</tr>
</table>
JS
$scope.checkboxClick = function (eventobj, item) {
if (eventobj.target.checked) {
$scope.selectedItems.push(item);
$scope.getLabel(item.id);
$scope.getOrderItems(item.id);
$scope.getPaymentItems(item.id);
} else {
$scope.removeItemFromSelection(item);
};
};
您或許對這個[的jsfiddle(http://jsfiddle.net/deeptechtons/TKVH6/)。 – arman1991