| filter: {name: someText}这种用$filter在controller中如何写啊

在controller中写currency过滤器是

$filter('currency')(12233243)

那如果要实现下面这个过滤器该怎么写呢?

<tr ng-repeat="product in products|filter:{brand: brandName}">
阅读 3.3k
2 个回答

我已经找到了。

$scope.filteredProducts = $filter('filter')($scope.products, $scope.brand);
angular.module('yourApp').filter('brand', function(){
    return function(input){
        // 逻辑
        
    }
})
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进