@@ -3,20 +3,35 @@ import {RouteDefinition} from './route_definition';
3
3
export { RouteDefinition } from './route_definition' ;
4
4
5
5
/**
6
- * You use the RouteConfig annotation to add routes to a component.
6
+ * The ` RouteConfig` decorator defines routes for a given component.
7
7
*
8
- * Supported keys:
9
- * - `path` (required)
10
- * - `component`, `loader`, `redirectTo` (requires exactly one of these)
11
- * - `as` (optional)
12
- * - `data` (optional)
8
+ * It takes an array of {@link RouteDefinition}s.
13
9
*/
14
10
@CONST ( )
15
11
export class RouteConfig {
16
12
constructor ( public configs : RouteDefinition [ ] ) { }
17
13
}
18
14
19
-
15
+ /**
16
+ * `Route` is a type of {@link RouteDefinition} used to route a path to a component.
17
+ *
18
+ * It has the following properties:
19
+ * - `path` is a string that uses the route matcher DSL.
20
+ * - `component` a component type.
21
+ * - `as` is an optional `CamelCase` string representing the name of the route.
22
+ * - `data` is an optional property of any type representing arbitrary route metadata for the given
23
+ * route. It is injectable via the {@link ROUTE_DATA} token.
24
+ *
25
+ * ## Example
26
+ * ```
27
+ * import {RouteConfig} from 'angular2/router';
28
+ *
29
+ * @RouteConfig ([
30
+ * {path: '/home', component: HomeCmp, as: 'HomeCmp' }
31
+ * ])
32
+ * class MyApp {}
33
+ * ```
34
+ */
20
35
@CONST ( )
21
36
export class Route implements RouteDefinition {
22
37
data : any ;
@@ -37,8 +52,26 @@ export class Route implements RouteDefinition {
37
52
}
38
53
}
39
54
40
-
41
-
55
+ /**
56
+ * `AuxRoute` is a type of {@link RouteDefinition} used to define an auxiliary route.
57
+ *
58
+ * It takes an object with the following properties:
59
+ * - `path` is a string that uses the route matcher DSL.
60
+ * - `component` a component type.
61
+ * - `as` is an optional `CamelCase` string representing the name of the route.
62
+ * - `data` is an optional property of any type representing arbitrary route metadata for the given
63
+ * route. It is injectable via the {@link ROUTE_DATA} token.
64
+ *
65
+ * ## Example
66
+ * ```
67
+ * import {RouteConfig, AuxRoute} from 'angular2/router';
68
+ *
69
+ * @RouteConfig ([
70
+ * new AuxRoute({path: '/home', component: HomeCmp})
71
+ * ])
72
+ * class MyApp {}
73
+ * ```
74
+ */
42
75
@CONST ( )
43
76
export class AuxRoute implements RouteDefinition {
44
77
data : any = null ;
@@ -55,6 +88,27 @@ export class AuxRoute implements RouteDefinition {
55
88
}
56
89
}
57
90
91
+ /**
92
+ * `AsyncRoute` is a type of {@link RouteDefinition} used to route a path to an asynchronously
93
+ * loaded component.
94
+ *
95
+ * It has the following properties:
96
+ * - `path` is a string that uses the route matcher DSL.
97
+ * - `loader` is a function that returns a promise that resolves to a component.
98
+ * - `as` is an optional `CamelCase` string representing the name of the route.
99
+ * - `data` is an optional property of any type representing arbitrary route metadata for the given
100
+ * route. It is injectable via the {@link ROUTE_DATA} token.
101
+ *
102
+ * ## Example
103
+ * ```
104
+ * import {RouteConfig} from 'angular2/router';
105
+ *
106
+ * @RouteConfig ([
107
+ * {path: '/home', loader: () => Promise.resolve(MyLoadedCmp), as: 'MyLoadedCmp'}
108
+ * ])
109
+ * class MyApp {}
110
+ * ```
111
+ */
58
112
@CONST ( )
59
113
export class AsyncRoute implements RouteDefinition {
60
114
data : any ;
@@ -69,6 +123,25 @@ export class AsyncRoute implements RouteDefinition {
69
123
}
70
124
}
71
125
126
+ /**
127
+ * `Redirect` is a type of {@link RouteDefinition} used to route a path to an asynchronously loaded
128
+ * component.
129
+ *
130
+ * It has the following properties:
131
+ * - `path` is a string that uses the route matcher DSL.
132
+ * - `redirectTo` is a string representing the new URL to be matched against.
133
+ *
134
+ * ## Example
135
+ * ```
136
+ * import {RouteConfig} from 'angular2/router';
137
+ *
138
+ * @RouteConfig ([
139
+ * {path: '/', redirectTo: '/home'},
140
+ * {path: '/home', component: HomeCmp}
141
+ * ])
142
+ * class MyApp {}
143
+ * ```
144
+ */
72
145
@CONST ( )
73
146
export class Redirect implements RouteDefinition {
74
147
path : string ;
0 commit comments