Created
June 30, 2015 19:17
-
-
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
This file contains hidden or 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