I wrote a search pipe to search a name and returns an array contains the name. Here searchTerm and key are strings.
My searchPipe is as follows:
export class SearchPipePipe implements PipeTransform {
  transform(data: any[], searchTerm: string, key: string): any[] {
    searchTerm = searchTerm.toUpperCase();
    return data.filter(item => {
      return item.key.toUpperCase().indexOf(searchTerm) !== -1
    });
  }
}
My html looks like
<input #input placeholder="Branch Name" id="search" [(ngModel)]="search" >
<div *ngFor="let item of BranchArray | searchPipe:input.value:'Br_Name'">
  {{item.Br_Name}}
</div>
But I got an error as "Cannot read property 'toUpperCase' of undefined" because I got item.key as undefined in the pipe. I want to convert the key from string
My array structure looks like
BranchArray=[{"Br_Name":"Branch Name 1"},
             {"Br_Name":"Branch Name 2"},
             {"Br_Name":"Branch Name 3"},
             {"Br_Name":"Branch Name 4"},
             {"Br_Name":"Branch Name 5"},
             {"Br_Name":"Branch Name 6"},
             {"Br_Name":"Branch Name 7"},
             {"Br_Name":"Branch Name 8"}]
