Skip to content
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

authService must be public to allow AoT #27

Open
Jan-PeterRichterCG opened this issue Mar 16, 2019 · 0 comments
Open

authService must be public to allow AoT #27

Jan-PeterRichterCG opened this issue Mar 16, 2019 · 0 comments

Comments

@Jan-PeterRichterCG
Copy link
Member

Category: Bug

Severity: Medium

Expected behaviour (In case of bug)
ng build --prod is able to build the project for production

Actual/current behaviour (In case of bug)
ng build --prod produces an error message:

ERROR in src\app\layout\header\header.component.html(3,69): : Property 'authService' is private and only accessible within class 'HeaderComponent'.

Steps to reproduce (In case of bug)
ng build --prod when finished the tutorial

Description of issue / expected enhacement /Comments
As described in https://github.com/devonfw/devonfw-tutorial-sources/wiki/build-devon4ng-application#separating-the-header-to-the-layout

Finally, the AuthService is needed because its being used by the html template to control if the user is logged in with isLogged().

....
  constructor(private authService: AuthService, private loginService: LoginService) { }
....

However, when building for production using --prod AoT is applied that recognizes the html as a separate class. (see https://medium.com/spektrakel-blog/angular-writing-aot-friendly-applications-7b64c8afbe3f for a discussion)

Solution:

....
  constructor(public authService: AuthService, private loginService: LoginService) { }
....

Now, the line <button mat-icon-button mdTooltip="Log out" (click)=onClickLogout() *ngIf="authService.isLogged()">in header.component.html is allowed to access authService.isLogged().

Your environment - windows/Linux, Devonfw version , component
irrelevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant