### File

`projects/commons/src/lib/elements/meta/guards/meta.guard.ts`

### Index

###### Methods
Public canActivate Public canActivateChild

### Constructor

`constructor(service: MetaService)`
Defined in projects/commons/src/lib/elements/meta/guards/meta.guard.ts:7
Parameters :
Name | Type | Optional
service | `MetaService` | No

### Methods

Public canActivate
`canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)`
Defined in projects/commons/src/lib/elements/meta/guards/meta.guard.ts:10
Parameters :
Name | Type | Optional
route | `ActivatedRouteSnapshot` | No
state | `RouterStateSnapshot` | No
Returns : `boolean`

Public canActivateChild
`canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)`
Defined in projects/commons/src/lib/elements/meta/guards/meta.guard.ts:21
Parameters :
Name | Type | Optional
route | `ActivatedRouteSnapshot` | No
state | `RouterStateSnapshot` | No
Returns : `boolean`

    import { Injectable } from '@angular/core';
    import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router';

    import { MetaService } from '../services';

    @Injectable()
    export class MetaGuard implements CanActivate, CanActivateChild {
        constructor(private readonly service: MetaService) {}

        public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
            const url = state.url;
            const settings = route.hasOwnProperty('data') && route.data.meta;

            if (settings) {
                this.service.update(url, settings);
            }

            return true;
        }

        public canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
            return this.canActivate(route, state);
        }
    }

# result-matching ""

# No results matching ""