Added nav-bar to show home link and user status

This commit is contained in:
Amritanshu
2019-08-22 14:15:02 +05:30
parent 04fb6dfcab
commit 05860fb0b9
9 changed files with 82 additions and 31 deletions

View File

@ -1,7 +1,5 @@
import { Component, OnInit} from '@angular/core';
import { AuthService} from '../auth/auth.service';
import { Observable } from 'rxjs';
import { map, share } from 'rxjs/operators';
@Component({
selector: 'app-home',
@ -9,15 +7,10 @@ import { map, share } from 'rxjs/operators';
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
public user: Observable<string>;
constructor(public auth: AuthService) {
}
ngOnInit() {
this.user = this.auth.userObservable.pipe(
map (x => x.isAuthenticated ? x.name : null),
share()
);
}
}