Estou acompanhando o projeto conforme as aulas, porém ao fazer o logout não carrega a página de login, somente o cabeçalho.
Erro
ERROR Error: Uncaught (in promise): Error: Method not implemented.
Error: Method not implemented.
at PhotoListComponent.push../src/app/photos/photo-list/photo-list.component.ts.PhotoListComponent.ngOnDestroy (photo-list.component.ts:15)
at callProviderLifecycles (core.js:9566)
at callElementProvidersLifecycles (core.js:9534)
at callLifecycleHooksChildrenFirst (core.js:9524)
at destroyView (core.js:10586)
at callWithDebugContext (core.js:11344)
at Object.debugDestroyView [as destroyView] (core.js:11028)
at ViewRef_.push../node_modules/@angular/core/fesm5/core.js.ViewRef_.destroy (core.js:8861)
at ComponentRef_.push../node_modules/@angular/core/fesm5/core.js.ComponentRef_.destroy (core.js:8698)
at RouterOutlet.push../node_modules/@angular/router/fesm5/router.js.RouterOutlet.deactivate (router.js:4768)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:3811)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1744)
header.component.ts
import { Component } from '@angular/core';
import { UserService } from '../user/user.service';
import { Observable } from 'rxjs';
import { User } from '../user/user';
import { Router } from '@angular/router';
@Component({
selector: 'ap-header',
templateUrl: './header.component.html'
})
export class HeaderComponent {
user$: Observable<User>;
constructor(
private userService: UserService,
private router: Router) {
this.user$ = userService.getUser();
}
logout() {
this.userService.logout();
this.router.navigate(['']);
}
}
header.component.html
<header class="sticky-top">
<nav class="navbar navbar-light bg-white">
<a class="navbar-brand">ALURAPIC</a>
<div *ngIf="(user$ | async) as user; else login"><!--usuario logado? se nao #login-->
<!--Com o pipe async conseguimos capturar a emissão do Observable direto do nosso template.-->
<i class="fa fa-user-circle mr-1"></i>
<a class="mr-1">{{ user.name}}</a>
<a (click)="logout()">(Logout)</a><!--ao clicar vai chamar o metodo logout do component header-->
</div>
<ng-template #login>
<span class="navbar-text">
Please, login!
</span>
</ng-template>
</nav>
</header>