import { Component , OnInit } from '@angular/core' ; import { ActivatedRoute } from '@angular/router' ; import { User , UserService , Profile } from '../core' ; import { concatMap , tap } from 'rxjs/operators' ; @ Component ( { selector : 'app-profile-page' , templateUrl : './profile.component.html' } ) export class ProfileComponent implements OnInit { constructor ( private route , private userService ) { } profile : Profile ; currentUser : User ; isUser : boolean ; ngOnInit ( ) { this . route . data . pipe ( concatMap ( ( data ) => { this . profile = data . profile ; return this . userService . currentUser . pipe ( tap ( ( userData ) => { this . currentUser = userData ; this . isUser = ( this . currentUser . username === this . profile . username ) ; } ) ) ; } ) ) . subscribe ( ) ; } onToggleFollowing ( following ) { this . profile . following = following ; } }