我試圖實現,當用戶點擊一個複選框時,它顯示ng-repeat中所有產品的數量爲0.否則,當複選框不勾選所有項目時顯示。目前我能夠獲得一半的功能。Stuck on angularjs ng-checked
複選框:
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" ng-checked="vm.OnHandQty()">
表
<tr ng-repeat="item in vm.items | filter :search">
<td ng-bind="item.itemNo"> </td>
<td ng-bind="item.description"></td>
<td ng-bind="(item.listPrice | currency)"></td>
<td ng-bind="item.onHandQty" ng-model="quantity"></td>
</tr>
控制器
vm.OnHandQty = function() {
$scope.search = {};
vm.items.forEach(i => {
if (i.onHandQty == 2) {
console.log(i);
$scope.search = i;
return true;
}
else {
$scope.search =i;
return false;
}
});
}
這消除了在支票上的所有對象和取消選中的地方他們回來 –
編輯我的答案。我忘記了包含「項目」有一個輸入到搜索功能 – vlin
我的錯誤的錯字謝謝 –