24 lines
571 B
TypeScript
24 lines
571 B
TypeScript
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',
|
|
templateUrl: './home.component.html',
|
|
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()
|
|
);
|
|
}
|
|
}
|