如何在角度过滤器函数中传递多个参数,而不是自定义过滤器 [英] How to pass multiple parameter in angular filter function, not custom filter
本文介绍了如何在角度过滤器函数中传递多个参数,而不是自定义过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我努力尝试并访问了很多类似的问题,但仍然无法解决此问题.
I tried hard and visit lot of similar question like this but still unable to solve this issue.
我想在角度过滤器函数中传递额外的参数.我找到了如下解决方案,但它不起作用.我在 ng-repeat
中使用的对象未定义.
I want to pass extra parameter in angular filter function. I found solution as below but it's not working. I am getting undefined for object which I have used in ng-repeat
.
<li ng-repeat="user in users | filter:isStatus(user,secondParam)">{{user.name}}</li>
有如下角度自定义过滤器的解决方案,但也不适用于角度过滤器功能.
There are solution for angular custom filter as below but that also not working with angular filter function.
<li ng-repeat="user in users | filter:isStatus:user:secondParam">{{user.name}}</li>
jsFiddle - 你可以在这里看到我的问题.
jsFiddle - You can see my problem here.
推荐答案
将尝试:
$scope.isStatus = function(secondParam, thirdParam){
return function(user) {
console.log(secondParam);
console.log(thirdParam);
return user.status == $scope.status;
}
更新版本http://jsfiddle.net/4PYZa/282/
这篇关于如何在角度过滤器函数中传递多个参数,而不是自定义过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文