Files
SkydiveLogs/Front/skydivelogs-app/src/app/app.component.ts
Sébastien André 11d4127c20 Ajout un "logout"
2020-03-13 16:30:41 +01:00

39 lines
1014 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { ServiceComm } from '../services/service-comm.service';
import { Router } from '@angular/router';
import { AuthenticationService } from '../services/authentication.service';
import { User } from '../models/user';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'app';
showMenu = false;
currentUser: User;
constructor(
private router: Router,
private authenticationService: AuthenticationService,
private serviceComm: ServiceComm
) {
this.authenticationService.currentUser.subscribe(x => this.currentUser = x);
}
ngOnInit() {
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
}
toggleMenu() {
this.showMenu = !this.showMenu;
}
logout() {
this.authenticationService.logout();
this.showMenu = !this.showMenu;
this.router.navigate(['/login']);
}
}