typescript 标识符是指组件的私有成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45520838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:47:35  来源:igfitidea点击:

Identifier refers to a private member of the component

angulartypescriptionic2ionic3

提问by Sampath

.html

.html

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

.ts

.ts

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

When I used the private memberas shown above it shows below error.I'm using Angular Language Serviceextension on VS codeeditor.

当我使用private member如上所示时,它显示以下错误。我在编辑器上使用Angular 语言服务扩展VS code

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

[Angular] 标识符“pickData”指的是组件的私有成员

Hope using private membersinside the component is good programming practice no? But as a solution for above issue was given as below comment on the extension's repo.

希望private members在组件内部使用是良好的编程习惯,不是吗?但是作为上述问题的解决方案,在扩展的 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).

语言服务会发出这些错误,因为它们将是 AOT 期间的错误。最终,您将需要解决这些问题。

我们计划支持访问 AOT 中的私有成员和受保护成员,但至少要到 6.0(明年春天)才会登陆。

So can you tell me what will be the best way to declare members on the components?

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

Update:

更新:

I use ionic cordova run android --prod --deviceCLI command with latest Ionic "ionic-angular": "3.5.3",.But it works nicely on my Android device.That means it is working fine with the AOTtoo no? Then why this error (or warning actually)?

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

采纳答案by Amit

They have to be publicin order for AoTto work.

他们必须是public为了AoT工作。

See here for a bit more details: https://github.com/angular/angular/issues/11978

有关更多详细信息,请参见此处:https: //github.com/angular/angular/issues/11978