import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , Resolve , RouterStateSnapshot } from '@angular/router' ; import { User } from '../models/user' ; import { Observable } from 'rxjs' ; import { UserService } from '../services/user.service' ; import { AuthService } from '../../auth/services/auth.service' ; @ Injectable ( { providedIn : 'root' } ) export class OwnUserResolver implements Resolve < User > { constructor ( private authService , private userService ) { } public resolve ( route , state ) { const userID = + this . authService . currentUserValue . public_id ; return this . userService . getUser ( userID ) ; } } @ Injectable ( { providedIn : 'root' } ) export class UserResolver implements Resolve < User > { constructor ( private userService ) { } public resolve ( route , state ) { const userID = + route . paramMap . get ( 'publicID' ) ; return this . userService . getUser ( userID ) ; } }