aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/routing/meta-guard.service.ts
blob: b68e06abe6f3506e108b6d824759252d83a50196 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot } from '@angular/router'
import { MetaService } from './meta.service'

@Injectable()
export class MetaGuard {

  constructor (private meta: MetaService) { }

  canActivate (route: ActivatedRouteSnapshot): boolean {
    const metaSettings = route.data?.meta

    if (metaSettings) {
      this.meta.update(metaSettings)
    }

    return true
  }

  canActivateChild (route: ActivatedRouteSnapshot): boolean {
    return this.canActivate(route)
  }
}