How to pass multiple parameter in angular filter function, not custom filter
NickName:Jay Shukla Ask DateTime:2014-12-16T22:39:54

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.

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 - You can see my problem here.

Copyright Notice:Content Author:「Jay Shukla」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/27507114/how-to-pass-multiple-parameter-in-angular-filter-function-not-custom-filter

Answers
user2700840 2014-12-16T15:03:16

Will try: \n\n$scope.isStatus = function(secondParam, thirdParam){\n return function(user) {\n console.log(secondParam);\n console.log(thirdParam);\n return user.status == $scope.status;\n }\n\n\nUpdated version http://jsfiddle.net/4PYZa/282/",


shawnzhu 2014-12-16T15:55:27

According to your case, you can use predicate expression instead of custom filter:\n\n<li ng-repeat=\"user in users | filter:{status: status, name: name}\">{{user.name}}</li>\n\n\nTake a look at this fiddle: http://jsfiddle.net/ovym2tpr/28/\n\nYou can use custom filter in anyway, it just performs not very well especially under nested ng-repeat",


JQuery Guru 2014-12-16T16:12:23

How do I call an Angular.js filter with multiple arguments?\n\nAngularJS : Custom filters and ng-repeat\n\n myApp.filter(\"isStatus \", function() { // register new filter\n return function(user, secondParam, thirdParam) { // filter arguments\n\n return user.status == $scope.status; // implementation\n };\n });\n\n\nCalling from Template\n\n<li ng-repeat=\"user in users | isStatus:secondParam\">{{user.name}}</li>\n",


More about “How to pass multiple parameter in angular filter function, not custom filter” related questions

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. I want to pass extra parameter in angular filter function. I found solution as below but it's not wor...

Show Detail

Angularjs pass an array to custom filter as parameter

When defining a custom filter in Angularjs like below I'm passing in the data set I want filtered and an array to serve as the filter values: Toggle buttons state passed in an array Parameter array

Show Detail

Call a function declared in a custom angular filter

I'm trying to call a declared function from my filter module: filterModule.filter({ functionFilterOne: ['CustomService', functionIDOne], functionFilterTwo: ['CustomService', functionIDTwo...

Show Detail

How to pass a two argument to a custom filter in angular js

I am trying to create a custom filter in angular js in that how to pass a two arguments in angularjs or other its possible to use a $scope and $rootScope inside a filter

Show Detail

How to pass $filter inside link function of angular directive

I need $filter inside the link function of angular directive but there is no way to pass $filter as a parameter to link function. app.directive('myDirective', function($compile) { return {

Show Detail

How to pass multiple filter parameters

How can you pass multiple parameters to a filter? This function in the compiled.php indicated that you use a comma as a separator protected static function parseParameterFilter($filter) { list($

Show Detail

Angular: Using a function as a custom filter

I am trying to filter ng-repeat, but am trying to use a function rather than an actual filter to filter the data. I was under the impression that something like this would work &lt;tr ng-repeat="...

Show Detail

Create custom Angular filter without app name

How to create custom angular filter without angular app name? // usual way for creating filter var app = angular.module('app', []); app.filter('makeUppercase', function () { return function (it...

Show Detail

Typescript: How to utilize angular $filter within custom filter

How can I utilize angular $filter within a custom filter? How to inject $filter dependency? module Filters { export class CustomFilter { public static Factory() { return

Show Detail

Passing a custom filter with attributes to a custom directive in angular

Is there a way to pass a custom filter as an attribute into a custom directive? So if I have a directive &lt;my-element value="1234" filter="my-filter:attr1:attr2"&gt;&lt;my-element&gt; as ang

Show Detail