angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Property is private and only accessible within class

Open aslan92 opened this issue 9 years ago • 41 comments

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

aslan92 avatar Mar 24 '17 10:03 aslan92

dupe of https://github.com/angular/angular-cli/issues/5620 please close

elvisbegovic avatar Mar 24 '17 10:03 elvisbegovic

no errors with angular v4.0.0

aslan92 avatar Mar 24 '17 10:03 aslan92

Is there a way to solve this error with angular 2.4?

stavn1 avatar Mar 24 '17 12:03 stavn1

rolling back to rc.4 fixed this for me

teodoradima avatar Mar 24 '17 16:03 teodoradima

image

The red text is via ng build --prod, however ng serve works just fine. This is a project I upgraded from ng2.4

alshdavid avatar Mar 26 '17 05:03 alshdavid

Same here. Apparently 1.0.0 only works with angular 4?

itsnotvalid avatar Mar 27 '17 11:03 itsnotvalid

Same here with cli 1.0.0 and angular 4

danzrou avatar Mar 31 '17 16:03 danzrou

Same here with cli 1.0.0 and angular 4

grassiricardo avatar Apr 01 '17 03:04 grassiricardo

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.

hccampos avatar Apr 01 '17 05:04 hccampos

I have resolved it with Angular 2.4.10, Angular-CLI 1.0.0-rc.2, and TypeScript 2.1.6

pcgeng avatar Apr 07 '17 06:04 pcgeng

I use cli 1.0.0 & angular 4 but still have this issue? any news please ?

da45 avatar Apr 18 '17 14:04 da45

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"

Blackbaud-SteveBrush avatar Apr 28 '17 16:04 Blackbaud-SteveBrush

+1 Reopen please.

bertolo1988 avatar May 07 '17 12:05 bertolo1988

same problem. unable to make prod build

aniruddhadas9 avatar May 08 '17 15:05 aniruddhadas9

same problem. any news?

ctrl-sflow avatar May 10 '17 15:05 ctrl-sflow

Set properties that will be accessed from the template to public and you're good to go

alshdavid avatar May 10 '17 19:05 alshdavid

We have also the same issue! "public" is not a solution.

j-nord avatar May 18 '17 16:05 j-nord

i have also the same issue. i use ver 4.0.1 with cli 1.0. how fix?

tsandtm avatar May 22 '17 15:05 tsandtm

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

toniopelo avatar May 29 '17 09:05 toniopelo

Guys, its a tslint.json issue. Ensure your configuration meets with what you set up on tslint.json

Hope it helps.

iamonuwa avatar Aug 17 '17 13:08 iamonuwa