search(searchTerm: string) {
this.handleSearchables(searchTerm);
}
private handleSearchables(searchTerm: string) {
for (const searchable of this.searchables) {
if (!searchTerm) {
searchable.show();
} else {
if (this.match(searchable)) {
searchable.show();
} else {
searchable.hide();
}
}
}
}
private match(searchable: SearchableDirective) {
return searchable.token.toLowerCase().indexOf(this._term.toLowerCase()) > -1;
}