2015-11-06 17:34:07 -08:00
|
|
|
import {CONST, Type} from 'angular2/src/facade/lang';
|
2015-07-13 16:12:48 -07:00
|
|
|
|
2015-09-21 14:43:24 -07:00
|
|
|
/**
|
|
|
|
* `RouteDefinition` defines a route within a {@link RouteConfig} decorator.
|
|
|
|
*
|
|
|
|
* Supported keys:
|
2015-10-30 17:05:30 -07:00
|
|
|
* - `path` or `aux` (requires exactly one of these)
|
2015-09-21 14:43:24 -07:00
|
|
|
* - `component`, `loader`, `redirectTo` (requires exactly one of these)
|
2015-10-25 15:00:27 +05:30
|
|
|
* - `name` or `as` (optional) (requires exactly one of these)
|
2015-09-21 14:43:24 -07:00
|
|
|
* - `data` (optional)
|
|
|
|
*
|
|
|
|
* See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}.
|
|
|
|
*/
|
2015-07-13 16:12:48 -07:00
|
|
|
export interface RouteDefinition {
|
2015-10-30 17:05:30 -07:00
|
|
|
path?: string;
|
|
|
|
aux?: string;
|
2015-07-13 16:12:48 -07:00
|
|
|
component?: Type | ComponentDefinition;
|
|
|
|
loader?: Function;
|
refactor(router): improve recognition and generation pipeline
This is a big change. @matsko also deserves much of the credit for the implementation.
Previously, `ComponentInstruction`s held all the state for async components.
Now, we introduce several subclasses for `Instruction` to describe each type of navigation.
BREAKING CHANGE:
Redirects now use the Link DSL syntax. Before:
```
@RouteConfig([
{ path: '/foo', redirectTo: '/bar' },
{ path: '/bar', component: BarCmp }
])
```
After:
```
@RouteConfig([
{ path: '/foo', redirectTo: ['Bar'] },
{ path: '/bar', component: BarCmp, name: 'Bar' }
])
```
BREAKING CHANGE:
This also introduces `useAsDefault` in the RouteConfig, which makes cases like lazy-loading
and encapsulating large routes with sub-routes easier.
Previously, you could use `redirectTo` like this to expand a URL like `/tab` to `/tab/posts`:
@RouteConfig([
{ path: '/tab', redirectTo: '/tab/users' }
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
Now the recommended way to handle this is case is to use `useAsDefault` like so:
```
@RouteConfig([
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
@RouteConfig([
{ path: '/posts', component: PostsCmp, useAsDefault: true, name: 'Posts' },
{ path: '/users', component: UsersCmp, name: 'Users' }
])
TabsCmp { ... }
```
In the above example, you can write just `['/Tab']` and the route `Users` is automatically selected as a child route.
Closes #4170
Closes #4490
Closes #4694
Closes #5200
Closes #5352
2015-11-02 16:14:10 -08:00
|
|
|
redirectTo?: any[];
|
2015-07-13 16:12:48 -07:00
|
|
|
as?: string;
|
2015-10-25 15:00:27 +05:30
|
|
|
name?: string;
|
2015-08-10 20:29:40 -04:00
|
|
|
data?: any;
|
refactor(router): improve recognition and generation pipeline
This is a big change. @matsko also deserves much of the credit for the implementation.
Previously, `ComponentInstruction`s held all the state for async components.
Now, we introduce several subclasses for `Instruction` to describe each type of navigation.
BREAKING CHANGE:
Redirects now use the Link DSL syntax. Before:
```
@RouteConfig([
{ path: '/foo', redirectTo: '/bar' },
{ path: '/bar', component: BarCmp }
])
```
After:
```
@RouteConfig([
{ path: '/foo', redirectTo: ['Bar'] },
{ path: '/bar', component: BarCmp, name: 'Bar' }
])
```
BREAKING CHANGE:
This also introduces `useAsDefault` in the RouteConfig, which makes cases like lazy-loading
and encapsulating large routes with sub-routes easier.
Previously, you could use `redirectTo` like this to expand a URL like `/tab` to `/tab/posts`:
@RouteConfig([
{ path: '/tab', redirectTo: '/tab/users' }
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
Now the recommended way to handle this is case is to use `useAsDefault` like so:
```
@RouteConfig([
{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }
@RouteConfig([
{ path: '/posts', component: PostsCmp, useAsDefault: true, name: 'Posts' },
{ path: '/users', component: UsersCmp, name: 'Users' }
])
TabsCmp { ... }
```
In the above example, you can write just `['/Tab']` and the route `Users` is automatically selected as a child route.
Closes #4170
Closes #4490
Closes #4694
Closes #5200
Closes #5352
2015-11-02 16:14:10 -08:00
|
|
|
useAsDefault?: boolean;
|
2015-07-13 16:12:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ComponentDefinition {
|
|
|
|
type: string;
|
|
|
|
loader?: Function;
|
|
|
|
component?: Type;
|
|
|
|
}
|