Noob
Noob

Reputation: 11

Angular 2. Property is private and only accessible within class

I'm trying to compile an angular 2 app using AOT. In my project I'm using angular-2-json-schema-form and it's causing errors like this:

Property is private and only accessible within class

when compiling my app.

I think that problem is in TypeScript. Somebody help me resolve this problem.

Upvotes: 1

Views: 7181

Answers (2)

Eliseo
Eliseo

Reputation: 57929

The most probable problem is that you have in a component.html some like {{myService.value}} or you have a enum and use directy in your component.html (e.g. .

If you are using myService.value, use a getter

get value(){
   return myService.value;
}
//in your .html
{{value}}

If your problem is because you're using an enum, declare a variable

IEnum=Enum

//in your .html
<div *ngIf="value==IEnum.Case1">

Upvotes: 1

Ronnie Hicks
Ronnie Hicks

Reputation: 11

Per this GitHub Issue, it's because prod builds use Ahead of Time compilation by default. You can work around it by turning off AOT, or by using public properties.

Upvotes: 1

Related Questions