[英]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
我有同样的问题。 我使用“我的索引”修复了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.