import { Component , OnInit } from "@angular/core" ; import { AuthService } from "../../services/auth.service" ; @ Component ( { selector : "app-login_for_navbar" , templateUrl : "./login_for_navbar.component.html" , styleUrls : [ "./login_for_navbar.component.css" ] } ) export class LoginForNavbarComponent implements OnInit { isConnected : boolean ; userName : string ; constructor ( private readonly authService ) { } ngOnInit ( ) { this . authService . authChanged . subscribe ( ( authStatus ) => { if ( authStatus ) { this . isConnected = authStatus . isConnected ; this . userName = authStatus . userName ; } } ) ; this . isConnected = this . authService . isLoggedIn ( ) ; if ( this . isConnected ) { this . userName = this . authService . getUserName ( ) ; } } login ( ) { this . authService . login ( ) ; return false ; } register ( ) { this . authService . register ( ) ; return false ; } logout ( ) { this . authService . logout ( ) ; return false ; } }