angular/modules/angular2/src/router/route_lifecycle_reflector.ts
vsavkin 79472b77ca refactor(core): move facades out of core
This is part of ongoing work to make core platform-independent.

BREAKING CHANGE

All private exports from 'angular2/src/core/facade/{lang,collection,exception_handler}' should be replaced with 'angular2/src/facade/{lang,collection,exception_handler}'.
2015-11-07 01:36:06 +00:00

21 lines
658 B
TypeScript

import {Type, isPresent} from 'angular2/src/facade/lang';
import {RouteLifecycleHook, CanActivate} from './lifecycle_annotations_impl';
import {reflector} from 'angular2/src/core/reflection/reflection';
export function hasLifecycleHook(e: RouteLifecycleHook, type): boolean {
if (!(type instanceof Type)) return false;
return e.name in(<any>type).prototype;
}
export function getCanActivateHook(type): Function {
var annotations = reflector.annotations(type);
for (let i = 0; i < annotations.length; i += 1) {
let annotation = annotations[i];
if (annotation instanceof CanActivate) {
return annotation.fn;
}
}
return null;
}