Property is private and only accessible within class
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.0 node: 6.9.5 os: linux x64 @angular/common: 2.4.10 @angular/compiler: 2.4.10 @angular/core: 2.4.10 @angular/forms: 2.4.10 @angular/http: 2.4.10 @angular/material: 2.0.0-beta.2 @angular/platform-browser: 2.4.10 @angular/platform-browser-dynamic: 2.4.10 @angular/router: 3.4.10 @angular/cli: 1.0.0 @angular/compiler-cli: 2.4.10
Repro steps.
ng build -prod
The log given by the failure.
ERROR in /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4028,18): Property '_sidenav' is private and only accessible within class 'AppComponent'. /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4030,18): Property '_infoSidenav' is private and only accessible within class 'AppComponent'. /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4032,18): Property '_owlCarousel' is private and only accessible within class 'AppComponent'. /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4034,18): Property '_tree' is private and only accessible within class 'AppComponent'. /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4036,18): Property '_ol3Map' is private and only accessible within class 'AppComponent'. /home/u/maps-msda-ng2/src/$$_gendir/app/app.component.ngfactory.ts (4524,22): Property '_extendedSearchAccordion' is private and only accessible within class 'AppComponent'.
Mention any other details that might be useful.
ng serve works
link to the code of the component: http://pastebin.com/p8EFtbFB
dupe of https://github.com/angular/angular-cli/issues/5620 please close
no errors with angular v4.0.0
Is there a way to solve this error with angular 2.4?
rolling back to rc.4 fixed this for me

The red text is via ng build --prod, however ng serve works just fine.
This is a project I upgraded from ng2.4
Same here. Apparently 1.0.0 only works with angular 4?
Same here with cli 1.0.0 and angular 4
Same here with cli 1.0.0 and angular 4
Duplicate, as said before.The Angular team will move to full AoT eventually and considers templates as separate entities from the component which means no private variables can be accessed from them. Basically, either convert your code or stay on Angular 2.4 or JIT.
I have resolved it with Angular 2.4.10, Angular-CLI 1.0.0-rc.2, and TypeScript 2.1.6
I use cli 1.0.0 & angular 4 but still have this issue? any news please ?
FYI, If you're only using @ngtools/webpack in your own custom webpack setup, these versions worked for me:
"@ngtools/webpack": "1.2.14",
"webpack": "2.3.3",
"webpack-dev-server": "2.4.5",
"webpack-merge": "4.1.0"
+1 Reopen please.
same problem. unable to make prod build
same problem. any news?
Set properties that will be accessed from the template to public and you're good to go
We have also the same issue! "public" is not a solution.
i have also the same issue. i use ver 4.0.1 with cli 1.0. how fix?
@j-nord @tsandtm Guys, this is not a bug from angular CLI. It's the way angular implements it. Actually the only bug there was here is that angular CLI didn't show the errors / warning of the compiler before the release. Now this bug is fixed and you can see the errors.
@j-nord Unfortunatelly, yes you will have to change all the components variable from private to public if they are used into your template. It's not a angular CLI issue, it's an angular requirements that was not well reported by the CLI until now.
The other option for you if you want to keep your variable private is to downgrade to @angular/cli-rc.4 and maybe stay on angular 2.x.x (not sure about that).
Another option I heard of (check by yourself, I didn't try) is that you only use JiT instead of AOT.
For more info you can check the comments of this issue #5623 Hope it helps.
Guys, its a tslint.json issue. Ensure your configuration meets with what you set up on tslint.json
Hope it helps.