NetanelBasal
11/16/2018 - 6:53 AM

search-4.ts

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;
}