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

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

问题描述

.html

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

.ts

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

当我使用上面显示的私有成员时,它显示如下错误。我正在使用 VS代码编辑器上的Angular.ng-templaterel =noreferrer> Angular Language Service 扩展名。

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

希望在组件内使用私有成员是不是很好的编程习惯?但是,作为上述问题的解决方案是 以下评论扩展程序的回购

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运行android - -prod --device CLI命令,带有最新的Ionic ionic-angular:3.5.3,。但它在我的Android上运行良好device.That意味着它与 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 工作。

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

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

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