Created
January 15, 2016 19:36
-
-
Save auxcoder/92f6eab5cce3e98360be to your computer and use it in GitHub Desktop.
Search by two atributes in an object (collections of customers)
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
| (function() { | |
| 'use strict'; | |
| angular.module('engageAngularApp') | |
| .filter('searchByNameAndPhone', function(){ | |
| return function(items, searchString){ | |
| if(!searchString){ | |
| return items; | |
| } | |
| var result = []; | |
| searchString = searchString.toLowerCase(); | |
| angular.forEach(items, function(item){ | |
| if(item.customer.first_name.toLowerCase().indexOf(searchString) !== -1 || item.customer.home_phone.toLowerCase().indexOf(searchString) !== -1 || item.customer.last_name.toLowerCase().indexOf(searchString) !== -1){ | |
| result.push(item); | |
| } | |
| }); | |
| return result; | |
| }; | |
| } | |
| ) | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment