Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created March 20, 2015 18:51
Show Gist options
  • Save bbrown/9e4229f0fd2a7349a209 to your computer and use it in GitHub Desktop.
Save bbrown/9e4229f0fd2a7349a209 to your computer and use it in GitHub Desktop.
Angular filter to dynamically call another filter
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);
};
});
@bbrown
Copy link
Author

bbrown commented Mar 20, 2015

Left as a StackOverflow answer as well - http://stackoverflow.com/a/29173220/20595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment