Skip to content

Instantly share code, notes, and snippets.

@luizcarraro
Created June 9, 2017 13:05
Show Gist options
  • Save luizcarraro/9b424a05c5e64b55316afc8cdc36bdc4 to your computer and use it in GitHub Desktop.
Save luizcarraro/9b424a05c5e64b55316afc8cdc36bdc4 to your computer and use it in GitHub Desktop.
An example of filter for ember arrays
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