feat(router): add support for using classes as guard
This commit is contained in:
16
modules/@angular/router/src/interfaces.ts
Normal file
16
modules/@angular/router/src/interfaces.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';
|
||||
|
||||
/**
|
||||
* An interface a class can implement to be a guard deciding if a route can be activated.
|
||||
*/
|
||||
export interface CanActivate {
|
||||
canActivate(route:ActivatedRouteSnapshot, state:RouterStateSnapshot):Observable<boolean> | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface a class can implement to be a guard deciding if a route can be deactivated.
|
||||
*/
|
||||
export interface CanDeactivate<T> {
|
||||
canDeactivate(component:T, route:ActivatedRouteSnapshot, state:RouterStateSnapshot):Observable<boolean> | boolean;
|
||||
}
|
Reference in New Issue
Block a user