AOT建構錯誤 property 'xxx' does not exist on type 'xxxComponent'

應該是確定是踩到AOT的點,只是搜尋過之後還是不知道怎麼解,有說模板中使用到東西都必須是public,但該變數已經是public的。

各位大神有空的話,幫忙研究一下:

build error:

ERROR in ng:///.../src/app/features/data/components/lite-list/lite-list.component.html (13,9): Property 'lite' does not exist on type 'LiteListComponent'.

(13, 9)

<tr *ngFor="let lite of liteList; index as i; trackBy: lite?.id">
@Input() liteList = [] as Lite[];

trackBy 我記得改成只能接受 function 了,所以你要在 component.ts 裡寫一個 function return lite.id

在頁面的部分,就改使用那個 function

這樣試試看

1個讚

Kevin is correct

FYI:
https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#ngForTrackBy-anchor

1個讚

確認。
拿掉就好了,感謝。

雖然不知道為什麼原因,但是改成只接受函數的似乎不若以前方便。

根據這篇的討論

by mhevery on Dec 10 2016
item[value] is problematic because it will be reflective. This will prevent property minification on the projects in the future. So app will run in normal mode, but once minified it would break it strange ways.

1個讚