Created
July 15, 2020 16:18
-
-
Save chani24/d9f87683c7d1f7e16c077f1c359c7a42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="nav-wrapper"> | |
<mat-toolbar class="nav"> | |
<span class="logo">Greenpot</span> | |
<img class="logo-img"src="https://www.pinclipart.com/picdir/big/2-23395_clipart-green-leaf-png-clipart-transparent-png.png"> | |
<span class="example-fill-remaining-space"></span> | |
<button mat-button routerLink="sign-in" *ngIf="!isAuthenticated">Sign in</button> | |
<button mat-button routerLink="register" *ngIf="!isAuthenticated">Register</button> | |
<button mat-icon-button *ngIf="isAuthenticated"><mat-icon>account_circle</mat-icon></button> | |
<mat-menu #appMenu="matMenu"> | |
<button mat-menu-item>Settings</button> | |
<button mat-menu-item>Help</button> | |
<button mat-menu-item (click)='signOut()'>Log out</button> | |
</mat-menu> | |
<button *ngIf="isAuthenticated" mat-icon-button [matMenuTriggerFor]="appMenu"> | |
<mat-icon>more_vert</mat-icon> | |
</button> | |
</mat-toolbar> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, OnDestroy } from '@angular/core'; | |
import { AuthService } from '../auth.service'; | |
@Component({ | |
selector: 'app-header', | |
templateUrl: './header.component.html', | |
styleUrls: ['./header.component.css'] | |
}) | |
export class HeaderComponent implements OnInit, OnDestroy { | |
constructor(private authservice: AuthService ){ | |
} | |
isAuthenticated; | |
ngOnInit(){ | |
this.authservice.getAuthStatus(); | |
this.authservice.currentAuthStatus.subscribe(authStatus => this.isAuthenticated = authStatus) | |
} | |
signOut(){ | |
this.authservice.signOut() | |
} | |
ngOnDestroy(){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you might rename getAuthStatus() at ngOnInit() at header.ts to authStatusListener()