Created
January 7, 2016 14:25
-
-
Save hkwid/8b86d9b61f6ca5f6fccd to your computer and use it in GitHub Desktop.
angularjs/regexFilter.js
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('regex', function() { | |
| return function(input, field, regex) { | |
| var pattern = new RegExp(regex); | |
| var out = []; | |
| for (var i = 0; i < input.length; i++){ | |
| if(pattern.test(input[i][field])) | |
| out.push(input[i]); | |
| } | |
| return out; | |
| }; | |
| }); |
Author
hkwid
commented
Jan 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment