### File

`src/app/header/header.component.ts`

### Metadata

selector | `app-header`
styleUrls | `header.component.scss`
templateUrl | `header.component.html`

### Constructor

`constructor(dataService: ApiService)`

### Methods

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 :

- state
  - Boolean representing the login state.

Returns: `void`

### Properties

loggedIn
`loggedIn: `boolean` </bcode>`

    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;
      }

    }

# results matching ""

# No results matching ""