src/app/header/header.component.ts
selector | app-header |
styleUrls | header.component.scss |
templateUrl | header.component.html |
constructor(dataService: ApiService)
|
Private changeState |
changeState(state: boolean)
|
Updates the state of the header to display the tab buttons in accordance with the state of whether the user is logged in.
Parameters :
Returns:
void
|
loggedIn |
loggedIn: |
import {Component, OnInit} from '@angular/core';
import {ApiService} from '../api.service';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
loggedIn: boolean;
constructor(private dataService: ApiService) {
}
ngOnInit(): void {
this.dataService.getLoggedInState.subscribe(state => this.changeState(state));
this.loggedIn = this.dataService.isLoggedIn();
}
/**
* Updates the state of the header to display the tab buttons in accordance with the state of whether the user is logged in.
* @param state - Boolean representing the login state.
* @private
*/
private changeState(state: boolean): void {
this.loggedIn = state;
}
}