简体   繁体   English

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

[英]Identifier refers to a private member of the component

.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 member as shown above it shows below error.I'm using Angular Language Service extension on VS code editor. 当我使用如上所示的private member ,它显示以下错误。我在VS code编辑器上使用Angular Language Service扩展。

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

Hope using private members inside the component is good programming practice no? 希望在组件内部使用private members是不是很好的编程习惯? But as a solution for above issue was given as below comment on the extension's repo . 但作为上述问题的解决方案, 如下面对扩展的回购评论

The language service will emit these errors because they will be errors during AOT. 语言服务将发出这些错误,因为它们在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中私人和受保护成员的访问,但至少在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 --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? 我使用ionic cordova run android --prod --device CLI命令与最新的离子"ionic-angular": "3.5.3",但它在我的Android设备上运行良好。这意味着它与AOT工作正常也没有? Then why this error (or warning actually)? 那为什么会出现这个错误(或实际警告)?

They have to be public in order for AoT to work. 他们必须public才能让AoT工作。

See here for a bit more details: https://github.com/angular/angular/issues/11978 有关详细信息,请参阅此处: https//github.com/angular/angular/issues/11978

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 标识符“ authService”是指组件的私有成员 - Identifier 'authService' refers to a private member of the component 标识符是指私有成员 - Identifier refers to a private member in angular 这个通知“标识符&#39;gridOptions&#39;是指componentAngular的私有成员”告诉我,我没有遵循编码最佳实践? - Is this notice “Identifier 'gridOptions' refers to a private member of the componentAngular” telling me that I am not following coding best practices? Angular 2子组件是指父组件 - Angular 2 child component refers to parent component 私有成员的ngOnInit可见性 - ngOnInit visibility of private member 将唯一标识符传递给angular 2组件? - Passing unique identifier to angular 2 component? Angular组件中的“私有”和“公共” - “private” and “public” in Angular component 标识符&#39;n&#39;未定义,&#39;object&#39;不包含此类成员 - Identifier 'n' not defined, 'object' does not contain such a member angular 5-当通过@Input将函数从组件传递到指令时,“ this”是指指令而不是Component - angular 5 - “this” refers to Directive instead of Component, when passing a function from component to directive through @Input 带有私人观察者的 Angular 2 多组件 - Angular 2 multiple component with a private observer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM