import { autoinject } from 'aurelia-framework' ; import { NavigationInstruction , RoutableComponentActivate , RoutableComponentCanActivate , RouteConfig } from 'aurelia-router' ; import { User } from '../models' ; import { UserRepository } from '../repository' ; @ autoinject ( ) export class UserPage implements RoutableComponentCanActivate , RoutableComponentActivate { user ? : User ; private readonly users : UserRepository ; constructor ( users ) { this . users = users ; } canActivate ( params , routeConfig , navigationInstruction ) { return params . id !== undefined ; } async activate ( params ) { this . user = await this . users . findById ( params . id ) ; } }