FarmMapsLib/projects/common/src/fm/services/nav-bar-guard.service.ts
Willem Dantuma 62887e8089
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
Implement canactivatechild also
2020-05-06 14:13:10 +02:00

31 lines
912 B
TypeScript

import { Injectable } from '@angular/core';
import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import * as appCommonActions from '../actions/app-common.actions';
@Injectable({
providedIn: 'root',
})
export class NavBarGuard implements CanActivate {
private loginDispatched = false;
constructor(private store: Store<appCommonReducer.State>) { }
setNavBar():boolean {
this.store.dispatch(new appCommonActions.ShowNavBar());
return true;
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setNavBar();
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.setNavBar();
}
}