标识符是指组件的私有成员 [英] Identifier refers to a private member of the component

查看:20
本文介绍了标识符是指组件的私有成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.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 语言服务 扩展在 VS 代码 编辑器上.

When I used the private member as shown above it shows below error.I'm using Angular Language Service extension on VS code editor.

[Angular] 标识符pickData"指的是组件

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

希望在组件内部使用 private members 是好的编程习惯,不是吗?但作为上述问题的解决方案,在 下面对扩展的回购.

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

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

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

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

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).

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

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

更新:

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

I use ionic cordova run android --prod --device CLI 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 AOT too no? Then why this error (or warning actually)?

推荐答案

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

They have to be public in order for AoT to work.

更多详情请参见此处:https://github.com/angular/angular/issues/11978

这篇关于标识符是指组件的私有成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆