Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created June 30, 2015 19:17
Show Gist options
  • Select an option

  • Save bbrown/dc071fa3432521fec115 to your computer and use it in GitHub Desktop.

Select an option

Save bbrown/dc071fa3432521fec115 to your computer and use it in GitHub Desktop.
Angular filter that takes a string (including arguments) and applies it as a filter to a string
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