]>
Commit | Line | Data |
---|---|---|
0f01a8ba | 1 | import { Injectable } from '@angular/core' |
9df52d66 | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild } from '@angular/router' |
0f01a8ba C |
3 | import { MetaService } from './meta.service' |
4 | ||
5 | @Injectable() | |
6 | export class MetaGuard implements CanActivate, CanActivateChild { | |
7 | ||
8 | constructor (private meta: MetaService) { } | |
9 | ||
10 | canActivate (route: ActivatedRouteSnapshot): boolean { | |
11 | const metaSettings = route.data?.meta | |
12 | ||
13 | if (metaSettings) { | |
14 | this.meta.update(metaSettings) | |
15 | } | |
16 | ||
17 | return true | |
18 | } | |
19 | ||
20 | canActivateChild (route: ActivatedRouteSnapshot): boolean { | |
21 | return this.canActivate(route) | |
22 | } | |
23 | } |