gpt4 book ai didi

angular - 标识符引用组件的私有(private)成员

转载 作者:太空狗 更新时间:2023-10-29 16:56:33 26 4
gpt4 key购买 nike

.html

  <offline-picks *ngFor="let pick of pickData" [data]="pick"></offline-picks>

.ts

export class OfflineArticlesPage {
private pickData: picksModel[] = [];
constructor(private localCacheService: LocalCacheServiceProvider) {
}
}

当我使用 private 成员 时,如上所示,它显示以下错误。我正在使用 Angular Language Service VS code 编辑器上的扩展。

[Angular] Identifier 'pickData' refers to a private member of the component

希望在组件内部使用私有(private)成员 是一种良好的编程习惯,不是吗?但作为上述问题的解决方案,给出了 below comment on the extension's repo .

The language service will emit these errors because they will be errors during AOT. Eventually, you will need to resolve these.

We have plans to support access to private and protected members in AOT but that will not land until at least 6.0 (spring of next year).

那么您能告诉我在组件上声明成员的最佳方式是什么吗?

更新:

我使用 ionic cordova run android --prod --device CLI 命令和最新的 Ionic "ionic-angular": "3.5.3",。但它有效在我的 Android 设备上运行良好。这意味着它在 AOT 上也能正常工作,不是吗?那为什么会出现这个错误(或者实际上是警告)?

最佳答案

它们必须是public才能使AoT工作。

更多细节请看这里: https://github.com/angular/angular/issues/11978

关于angular - 标识符引用组件的私有(private)成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45520838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com