Files
barker/bookie/src/app/home/home.component.ts
2019-08-21 00:07:46 +05:30

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()
);
}
}