39 lines
1014 B
TypeScript
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']);
|
|
}
|
|
}
|