-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property is private and only accessible within class #5621
Comments
dupe of #5620 |
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 |
Same here. Apparently 1.0.0 only works with angular 4? |
Same here with cli 1.0.0 and angular 4 |
1 similar comment
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 ? |
The Angular team considers templates as separate entities from the component which means no private/protected variables can be accessed from them angular/angular-cli#5621
FYI, If you're only using @ngtools/webpack in your own custom webpack setup, these versions worked for me:
|
+1 Reopen please. |
same problem. unable to make prod build |
same problem. any news? |
Set properties that will be accessed from the template to |
We have also the same issue! "public" is not a solution. |
i have also the same issue. |
@j-nord @tsandtm @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 For more info you can check the comments of this issue #5623 |
Guys, its a tslint.json issue. Ensure your configuration meets with what you set up on tslint.json Hope it helps. |
@iamonuwa Could you please elaborate on how to do that? |
running this command to deploy the app will fix it.. ng build --env=prod found the solution in github |
ng build --env=prod worked. @deeptiProjects can you describe the difference |
@deeptiProjects @arun31786 with Original "error" reported is not an error, but normal restriction of AOT at least for versions 2, 4, 5. The variable used in the template needs to be declared as "public". Template is treated as a separate Typescript class. |
ng build -prod --aot=false |
@arun31786 Documentation claims those commands are the same:
|
Try |
I have also the same issue! |
Same issue here after angular 5 update. I don't want to make all properties en methods public. |
I used angular 2.4.10 , angular-cli 1.0.6 ,typescript 2.2.1 |
I used angular 5.0.5 and cli 1.5.5 have same problem too.
So, we can't use "ng build --prod" ? |
+1 Property 'nav' (nav is a private instance of a component in constructor) is private and only accessible within class. Angular 5.1+ This errormsg appears when ng build --prod |
I have several instances of the same injected variable and it's private in some places and public in others, and it's used in some templates as a private variable, yet one module is complaining that it's private, and the rest aren't. |
+1 |
I am using Angular 5 and having the same issue when deploying Jenkins build. The annoying part is it works locally but not when I make a build |
Changing to public when used in templates worked for me. Not sure why only one module complained though. |
-Note: Will have to port this to master for next release. Required for aot compilation and all future versions of angular. see angular/angular-cli#5621
Same, cannot make a build for production, this is quite annoying. |
I had the same issue. What I understood, the most correct way is to define your variables as public when planning on using them in a template. With that said I ended up having to change 1000+ properties in my components. In order to do that efficiently I created this python-script: Hope that can help some others to speed up the migration from private properties to public properties in your projects! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)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
workslink to the code of the component: http://pastebin.com/p8EFtbFB
The text was updated successfully, but these errors were encountered: