Skip to content

authService must be public to allow AoT #27

@Jan-PeterRichterCG

Description

@Jan-PeterRichterCG

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions