NetanelBasal
11/16/2018 - 7:38 AM

search-421.ts

@Component({...})
export class SearchableContainerComponent {

  private _count = 0;
  get count() {
    return this._count;
  }

  set count(count: number) {
    this._count = count;
  }
  
  ...

  private handleSearchables(searchTerm: string) {
    let count = 0;
    for (const searchable of this.searchables) {
      if (!searchTerm) {
        searchable.show();
        count++;
      } else {
        if (this.match(searchable)) {
          searchable.show();
          count++;
        } else {
          searchable.hide();
        }
      }
    }
    this.count = count;
  }
  
  ...

}