Я хочу изменить заголовок, когда пользователь вошел в систему, но я не могу. Перенаправление работает хорошо, и центр страницы меняется, но заголовок - нет.
Эта функция используется при нажатии кнопки «Вход» в компоненте аутентификации
LoginFormSubmit(LoginForm){
return this.http.post(environment.laravel_api+'/login',LoginForm.value).subscribe(
data => this.afterLogin(data) ,
error => console.log(error)
);
}
afterLogin (данные) {
this.user.setSession(data['user']);
this.route.navigateByUrl('');
}
Вот мой компонент заголовка:
session;
constructor(private user: UserService, private http: HttpClient, private route: Router) {
}
ngOnInit(): void {
console.log("Dentro");
this.session = this.user.getSession();
}
Logout(){
localStorage.clear();
this.afterLogout();
}
afterLogout(){
this.route.initialNavigation();
}
А вот пользовательская служба:
constructor() { }
setSession(session_data){
localStorage.setItem('session', JSON.stringify(session_data));
}
getSession(){
return JSON.parse(localStorage.getItem('session'));
}