1 | import { ComponentInstruction } from '../instruction';
|
2 | export { routerCanDeactivate, routerCanReuse, routerOnActivate, routerOnDeactivate, routerOnReuse } from './lifecycle_annotations_impl';
|
3 | /**
|
4 | * Defines route lifecycle hook `CanActivate`, which is called by the router to determine
|
5 | * if a component can be instantiated as part of a navigation.
|
6 | *
|
7 | * <aside class="is-right">
|
8 | * Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
|
9 | * This is because the `CanActivate` function is called before the component is instantiated.
|
10 | * </aside>
|
11 | *
|
12 | * The `CanActivate` hook is called with two {@link ComponentInstruction}s as parameters, the first
|
13 | * representing the current route being navigated to, and the second parameter representing the
|
14 | * previous route or `null`.
|
15 | *
|
16 | * ```typescript
|
17 | * @CanActivate((next, prev) => boolean | Promise<boolean>)
|
18 | * ```
|
19 | *
|
20 | * If `CanActivate` returns or resolves to `false`, the navigation is cancelled.
|
21 | * If `CanActivate` throws or rejects, the navigation is also cancelled.
|
22 | * If `CanActivate` returns or resolves to `true`, navigation continues, the component is
|
23 | * instantiated, and the {@link OnActivate} hook of that component is called if implemented.
|
24 | *
|
25 | * ### Example
|
26 | *
|
27 | * {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
|
28 | */
|
29 | export declare var CanActivate: (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean> | boolean) => ClassDecorator;
|