Angular trackBy giving Missing Properties Error

352 Views Asked by At

I am using track by function in my ionic angular app and while building the app, it gives me error: Type '(index: any, item: any) => any' is missing the following properties from type 'any[]': pop, push, concat, join, and 25 more.

I am using this function as:

html:

<div *ngFor="let group of groups; index as i; trackBy: trackByFn | groupFilter: searchGroup">

component:

trackByFn(index, item) {
    return item.key;
  }

any idea what am i doing wrong? Thanks for help.

1

There are 1 best solutions below

0
On

you are using filter in wrong place. the correct variant would be

<div *ngFor="let group of groups | groupFilter: searchGroup; index as i; trackBy: trackByFn">