【发布时间】:2016-05-05 05:26:11
【问题描述】:
我正在尝试实现,当用户单击复选框时,它会在 ng-repeat 中显示数量为 0 的所有产品。否则,当复选框未选中所有项目显示时。目前我能够获得一半的功能。
复选框:
<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;
}
});
}
【问题讨论】:
标签: angularjs angularjs-ng-repeat angular-filters