/
setwind
/
City
Обзор
Документация
Войти
/
setwind
/
City
Код
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
frontend/src/app/component/header/header.component.ts
32 строки
1 KB
InfinityExistence
add fronted and isAuthenticated
19 май 2025, 11:16
19 май 2025, 11:16
697ae4c
Код
Авторство
О чём код?
import {Component} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {MatButtonModule} from '@angular/material/button'; import {MatToolbarModule} from '@angular/material/toolbar'; import {AuthenticationService} from '../../service/authentication.service'; import {AsyncPipe} from '@angular/common'; import {Observable} from 'rxjs'; import {Router} from '@angular/router'; @Component({ selector: 'app-header', imports: [MatButtonModule, MatToolbarModule, AsyncPipe], templateUrl: './header.component.html', styleUrl: './header.component.css' }) export class HeaderComponent { isAuthenticated: Observable<Boolean>; location = window.location constructor(private http: HttpClient, private authenticationService: AuthenticationService, private router: Router) { this.isAuthenticated = authenticationService.isAuthenticated() } redirectToLogin() { window.location.href = "/login" } makeLogout() { this.http.get("/logout", {responseType: 'text'}).subscribe(window.location.reload.bind(this.location)); } }