Created
March 20, 2015 18:51
-
-
Save bbrown/9e4229f0fd2a7349a209 to your computer and use it in GitHub Desktop.
Angular filter to dynamically call another filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app").filter("meta", function($filter) | |
{ | |
return function() | |
{ | |
var filterName = [].splice.call(arguments, 1, 1)[0] || "filter"; | |
var filter = filterName.split(":"); | |
if (filter.length > 1) | |
{ | |
filterName = filter[0]; | |
for (var i = 1, k = filter.length; i < k; i++) | |
{ | |
[].push.call(arguments, filter[i]); | |
} | |
} | |
return $filter(filterName).apply(null, arguments); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Left as a StackOverflow answer as well - http://stackoverflow.com/a/29173220/20595