import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , CanActivate , CanActivateChild , RouterStateSnapshot } from '@angular/router' ; import { MetaService } from './meta.service' ; @ Injectable ( ) export class MetaGuard implements CanActivate , CanActivateChild { constructor ( private readonly meta ) { } canActivate ( route , state ) { const url = state . url ; const metaSettings = route . hasOwnProperty ( 'data' ) ? route . data . meta : undefined ; this . meta . update ( url , metaSettings ) ; return true ; } canActivateChild ( route , state ) { return this . canActivate ( route , state ) ; } }