import { Component } from '@angular/core' ; import { first } from 'rxjs/operators' ; import { User } from '@app/_models' ; import { UserService , AuthenticationService } from '@app/_services' ; @ Component ( { templateUrl : 'home.component.html' } ) export class HomeComponent { loading = false ; currentUser : User ; userFromApi : User ; constructor ( private userService , private authenticationService ) { this . currentUser = this . authenticationService . currentUserValue ; } ngOnInit ( ) { this . loading = true ; this . userService . getById ( this . currentUser . id ) . pipe ( first ( ) ) . subscribe ( user => { this . loading = false ; this . userFromApi = user ; } ) ; } }