0
我有塊帶過濾器:如何激活複選框角度的過濾功能?
<form action="">
<input type="checkbox" id="inp1">
<label for="inp1">All items</label>
<input type="checkbox" id="inp2">
<label for="inp2">New today</label>
<input type="checkbox" id="inp3">
<label for="inp3">New this week</label>
<input type="checkbox" id="inp4">
<label for="inp4">Free delivery</label>
</form>
的 「新今日」 和 「本週新品」 過濾器:
$scope.newThisWeek = function(products){
$scope.time = (Date.now() - Date.parse(products.add_update_time));
if ($scope.time <= 604800000) {
return $scope.products;
} else {
return null;
}
};
$scope.newToday = function(products){
$scope.time = (Date.now() - Date.parse(products.add_update_time));
if ($scope.time <= 86400000) {
return $scope.products;
} else {
return null;
}
};
使用過濾器,因爲:
<div class="catalog-item" ng-repeat="product in products |filter:newThisWeek|filter:newToday">
<a href="{{product.external_url}}" class="item-title">{{ product.name }}</a>
</div>
如何激活複選框角度的過濾功能?