Created
June 9, 2017 13:05
-
-
Save luizcarraro/9b424a05c5e64b55316afc8cdc36bdc4 to your computer and use it in GitHub Desktop.
An example of filter for ember arrays
This file contains 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
filterContacts(filter) { | |
var list = this.get('list'); | |
return list.filter(function (item) { | |
if(_match(item.name) || _match(item.professionalEmail) || _match(item.jobFunction) || _match(item.department) || _match(item.professionalPhone)) { | |
return true; | |
} else { | |
return false; | |
} | |
}); | |
function _match(base) { | |
return base && filter.some(function _anyMatch(item) { | |
return base.match(new RegExp($.trim(item),'i')); | |
}); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment