简体   繁体   English

Angular track 通过给出缺失属性错误

[英]Angular trackBy giving Missing Properties Error

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.我在我的 ionic angular 应用程序中使用按功能跟踪,在构建应用程序时,它给了我错误:类型 '(index: any, item: any) => any' 缺少类型 'any[]' 中的以下属性: pop、push、concat、join 等 25 个。

I am using this function as:我将此功能用作:

html: 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.感谢帮助。

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">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM