navbar.component.ts 825 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { AuthService } from 'src/app/services/auth.service';
  2. import { Component, OnInit, Output } from '@angular/core';
  3. import { User } from '../../../models/userResponse';
  4. @Component({
  5. selector: 'app-navbar',
  6. templateUrl: './navbar.component.html',
  7. styleUrls: ['./navbar.component.scss']
  8. })
  9. export class NavbarComponent implements OnInit {
  10. isLogged: User;
  11. isAdmin: boolean = false;
  12. constructor(private authService : AuthService) {
  13. console.log('Variable', this.isAdmin)
  14. this.authService.user_info.subscribe((x) =>{
  15. this.isLogged = x;
  16. this.isLogged.role ==='admin' ? this.isAdmin = true : this.isAdmin = false;
  17. console.log('Variable dedans', this.isAdmin);
  18. });
  19. }
  20. ngOnInit(): void {
  21. //console.log(this.isLogged)
  22. }
  23. logOut(){
  24. this.authService.logout()
  25. }
  26. }