繁体   English   中英

类型不存在属性“ indx”

[英]Property 'indx' does not exist on type

我一直在从事Angular 5项目,并尝试将npm build -prod与AOT结合使用。 编译错误后弹出为

Property 'indx' does not exist on type 'EntryComponent'

可以指出任何错误。 还是其他的东西。

<div *ngFor="let form of getEntryGroupItemsControl(); let indx = index; trackBy: indx">

原因是语法错误。 trackBy应该指向一个函数,而不是循环中的索引。 所以它应该是这样的:

<div *ngFor="let form of getEntryGroupItemsControl(); let indx = index; trackBy: trackByFn">

并以TS文件为例:

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

作为参考,请参见:1) https://angular.io/api/common/NgForOf 2) https://angular.io/api/core/TrackByFunction

这是来自官方Angular教程的示例: https ://angular.io/guide/template-syntax#ngfor-with-trackby

我有同样的问题。 我使用“我的索引”修复了它。

https://angular.io/api/common/NgForOf

暂无
暂无

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

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