[英]AngularJS: how to filter by two expressions with $filter
這是$ fiter文檔: https ://docs.angularjs.org/api/ng/filter/filter
我完成以下工作:
$scope.images = $filter('filter')(imageList, { type: 'snapshot' });
$scope.images = $filter('filter')($scope.images, { status: 'ACTIVE' });
但是我想重構和簡化代碼,最好使用一行代碼而不是兩行。
我環顧四周,有人建議使用自定義過濾器。 有沒有一種方法可以通過直接使用$ filter來實現?
提前致謝!
我認為您可以像這樣將兩者結合在一起:
$scope.images = $filter('filter')(imageList, { type: 'snapshot', status: 'ACTIVE' });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.