@angular-wave/angular.ts 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +6 -5
- package/dist/angular-ts.esm.js +2 -1
- package/dist/angular-ts.umd.js +1 -1
- package/package.json +2 -4
- package/rollup.config.js +5 -1
- package/src/core/scope/scope.js +4 -7
- package/src/index.js +307 -1
- package/src/loader.js +13 -6
- package/src/public.js +7 -2
- package/src/src.test.js +10 -0
- package/tsconfig.json +1 -1
- package/tsconfig.types.json +11 -0
- package/types/animations/animate-cache.d.ts +7 -7
- package/types/animations/animate-children-directive.d.ts +3 -6
- package/types/animations/animate-swap.d.ts +7 -16
- package/types/animations/animation.d.ts +2 -11
- package/types/animations/raf-scheduler.d.ts +3 -3
- package/types/animations/shared.d.ts +8 -23
- package/types/core/{animate-css.d.ts → animate/animate-css.d.ts} +2 -8
- package/types/core/{cache.d.ts → cache/cache.d.ts} +5 -5
- package/types/core/compile/compile.d.ts +173 -0
- package/types/core/controller/controller.d.ts +32 -0
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/filter/filter.d.ts +9 -0
- package/types/core/{interpolate.d.ts → interpolate/interpolate.d.ts} +23 -39
- package/types/core/interval/interval-factory.d.ts +4 -0
- package/types/core/{interval.d.ts → interval/interval.d.ts} +1 -1
- package/types/core/location/location.d.ts +209 -0
- package/types/core/pubsub/pubsub.d.ts +156 -0
- package/types/core/q/q.d.ts +31 -0
- package/types/core/sanitize/sanitize-uri.d.ts +53 -0
- package/types/core/{sce.d.ts → sce/sce.d.ts} +80 -86
- package/types/core/scope/scope.d.ts +727 -0
- package/types/core/task-tracker-factory.d.ts +29 -29
- package/types/core/timeout/timeout.d.ts +20 -0
- package/types/core/{urlUtils.d.ts → url-utils/url-utils.d.ts} +2 -7
- package/types/directive/{bind.d.ts → bind/bind.d.ts} +4 -10
- package/types/directive/{class.d.ts → class/class.d.ts} +12 -21
- package/types/directive/controller/controller.d.ts +6 -0
- package/types/directive/events/events.d.ts +5 -0
- package/types/directive/form/form.d.ts +200 -0
- package/types/directive/if/if.d.ts +8 -0
- package/types/directive/include/include.d.ts +14 -0
- package/types/directive/{input.d.ts → input/input.d.ts} +20 -69
- package/types/directive/{model.d.ts → model/model.d.ts} +256 -279
- package/types/directive/options/options.d.ts +9 -0
- package/types/directive/ref/ref.d.ts +5 -0
- package/types/directive/repeat/repeat.d.ts +8 -0
- package/types/directive/{script.d.ts → script/script.d.ts} +5 -8
- package/types/directive/{show-hide.d.ts → show-hide/show-hide.d.ts} +10 -16
- package/types/directive/switch/switch.d.ts +17 -0
- package/types/directive/transclude/transclude.d.ts +4 -0
- package/types/directive/{validators.d.ts → validators/validators.d.ts} +20 -35
- package/types/filters/filters.d.ts +10 -16
- package/types/filters/order-by.d.ts +2 -4
- package/types/index.d.ts +117 -0
- package/types/injector.d.ts +12 -0
- package/types/public.d.ts +5 -0
- package/types/router/common/coreservices.d.ts +2 -2
- package/types/router/common/glob.d.ts +9 -9
- package/types/router/common/queue.d.ts +13 -13
- package/types/router/common/trace.d.ts +43 -43
- package/types/router/directives/view-directive.d.ts +13 -32
- package/types/router/globals.d.ts +20 -20
- package/types/router/hooks/lazy-load.d.ts +2 -11
- package/types/router/hooks/redirect-to.d.ts +1 -4
- package/types/router/hooks/url.d.ts +1 -5
- package/types/router/hooks/views.d.ts +1 -4
- package/types/router/params/param-factory.d.ts +5 -5
- package/types/router/params/param-type.d.ts +35 -35
- package/types/router/params/param-types.d.ts +11 -11
- package/types/router/params/param.d.ts +38 -38
- package/types/router/params/state-params.d.ts +10 -10
- package/types/router/path/path-node.d.ts +34 -34
- package/types/router/path/path-utils.d.ts +73 -77
- package/types/router/resolve/resolvable.d.ts +32 -32
- package/types/router/resolve/resolve-context.d.ts +84 -84
- package/types/router/services.d.ts +4 -9
- package/types/router/state/state-builder.d.ts +27 -27
- package/types/router/state/state-matcher.d.ts +5 -5
- package/types/router/state/state-object.d.ts +58 -58
- package/types/router/state/state-queue-manager.d.ts +10 -16
- package/types/router/state/state-registry.d.ts +100 -107
- package/types/router/state/state-service.d.ts +411 -411
- package/types/router/state/target-state.d.ts +64 -69
- package/types/router/state/views.d.ts +31 -37
- package/types/router/state-filters.d.ts +7 -7
- package/types/router/state-provider.d.ts +105 -105
- package/types/router/template-factory.d.ts +83 -112
- package/types/router/transition/hook-builder.d.ts +25 -25
- package/types/router/transition/hook-registry.d.ts +68 -83
- package/types/router/transition/interface.d.ts +7 -7
- package/types/router/transition/reject-factory.d.ts +34 -34
- package/types/router/transition/transition-event-type.d.ts +9 -18
- package/types/router/transition/transition-hook.d.ts +77 -82
- package/types/router/transition/transition-service.d.ts +82 -99
- package/types/router/transition/transition.d.ts +369 -377
- package/types/router/url/url-config.d.ts +84 -84
- package/types/router/url/url-matcher.d.ts +115 -119
- package/types/router/url/url-rule.d.ts +114 -124
- package/types/router/url/url-rules.d.ts +217 -217
- package/types/router/url/url-service.d.ts +264 -269
- package/types/router/view/view.d.ts +114 -117
- package/types/router/view-scroll.d.ts +2 -2
- package/types/services/anchor-scroll.d.ts +2 -8
- package/types/services/browser.d.ts +122 -130
- package/types/services/cache-factory.d.ts +25 -25
- package/types/services/cookie-reader.d.ts +2 -2
- package/types/services/document.d.ts +2 -2
- package/types/services/http/http.d.ts +145 -0
- package/types/services/{http-backend.d.ts → http-backend/http-backend.d.ts} +3 -35
- package/types/services/log.d.ts +49 -49
- package/types/services/template-request.d.ts +44 -53
- package/types/shared/common.d.ts +4 -19
- package/types/{constants.d.ts → shared/constants.d.ts} +6 -6
- package/types/shared/hof.d.ts +1 -1
- package/types/{jqLite.d.ts → shared/jqlite/jqlite.d.ts} +11 -11
- package/types/shared/test-utils.d.ts +11 -0
- package/types/shared/utils.d.ts +7 -24
- package/types-back/global.d.ts +3 -1
- package/types-back/index.d.ts +2 -221
- package/types/core/compile.d.ts +0 -206
- package/types/core/controller.d.ts +0 -42
- package/types/core/filter.d.ts +0 -9
- package/types/core/interval-factory.d.ts +0 -21
- package/types/core/location.d.ts +0 -234
- package/types/core/pubsub.d.ts +0 -164
- package/types/core/q.d.ts +0 -33
- package/types/core/root-scope.d.ts +0 -754
- package/types/core/sanitize-uri.d.ts +0 -57
- package/types/core/timeout.d.ts +0 -31
- package/types/directive/controller.d.ts +0 -6
- package/types/directive/events.d.ts +0 -12
- package/types/directive/form.d.ts +0 -230
- package/types/directive/if.d.ts +0 -17
- package/types/directive/include.d.ts +0 -33
- package/types/directive/options.d.ts +0 -16
- package/types/directive/ref.d.ts +0 -11
- package/types/directive/repeat.d.ts +0 -23
- package/types/directive/switch.d.ts +0 -23
- package/types/directive/transclude.d.ts +0 -15
- package/types/services/http.d.ts +0 -157
- /package/types/directive/{attrs.d.ts → attrs/attrs.d.ts} +0 -0
- /package/types/directive/{change.d.ts → change/change.d.ts} +0 -0
- /package/types/directive/{cloak.d.ts → cloak/cloak.d.ts} +0 -0
- /package/types/directive/{init.d.ts → init/init.d.ts} +0 -0
- /package/types/directive/{list.d.ts → list/list.d.ts} +0 -0
- /package/types/directive/{non-bindable.d.ts → non-bindable/non-bindable.d.ts} +0 -0
- /package/types/directive/{style.d.ts → style/style.d.ts} +0 -0
- /package/types/exts/{aria.d.ts → aria/aria.d.ts} +0 -0
- /package/types/exts/{messages.d.ts → messages/messages.d.ts} +0 -0
|
@@ -9,221 +9,221 @@
|
|
|
9
9
|
* This API is found at `$urlService.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
|
|
10
10
|
*/
|
|
11
11
|
export class UrlRules {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
12
|
+
constructor(urlRuleFactory: any);
|
|
13
|
+
_sortFn: any;
|
|
14
|
+
_rules: any[];
|
|
15
|
+
_id: number;
|
|
16
|
+
urlRuleFactory: any;
|
|
17
|
+
/**
|
|
18
|
+
* Defines the initial state, path, or behavior to use when the app starts.
|
|
19
|
+
*
|
|
20
|
+
* This rule defines the initial/starting state for the application.
|
|
21
|
+
*
|
|
22
|
+
* This rule is triggered the first time the URL is checked (when the app initially loads).
|
|
23
|
+
* The rule is triggered only when the url matches either `""` or `"/"`.
|
|
24
|
+
*
|
|
25
|
+
* Note: The rule is intended to be used when the root of the application is directly linked to.
|
|
26
|
+
* When the URL is *not* `""` or `"/"` and doesn't match other rules, the [[otherwise]] rule is triggered.
|
|
27
|
+
* This allows 404-like behavior when an unknown URL is deep-linked.
|
|
28
|
+
*
|
|
29
|
+
* #### Example:
|
|
30
|
+
* Start app at `home` state.
|
|
31
|
+
* ```js
|
|
32
|
+
* .initial({ state: 'home' });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* #### Example:
|
|
36
|
+
* Start app at `/home` (by url)
|
|
37
|
+
* ```js
|
|
38
|
+
* .initial('/home');
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* #### Example:
|
|
42
|
+
* When no other url rule matches, go to `home` state
|
|
43
|
+
* ```js
|
|
44
|
+
* .initial((matchValue, url, router) => {
|
|
45
|
+
* console.log('initial state');
|
|
46
|
+
* return { state: 'home' };
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param handler The initial state or url path, or a function which returns the state or url path (or performs custom logic).
|
|
51
|
+
*/
|
|
52
|
+
initial(handler: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Defines the state, url, or behavior to use when no other rule matches the URL.
|
|
55
|
+
*
|
|
56
|
+
* This rule is matched when *no other rule* matches.
|
|
57
|
+
* It is generally used to handle unknown URLs (similar to "404" behavior, but on the client side).
|
|
58
|
+
*
|
|
59
|
+
* - If `handler` a string, it is treated as a url redirect
|
|
60
|
+
*
|
|
61
|
+
* #### Example:
|
|
62
|
+
* When no other url rule matches, redirect to `/index`
|
|
63
|
+
* ```js
|
|
64
|
+
* .otherwise('/index');
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* - If `handler` is an object with a `state` property, the state is activated.
|
|
68
|
+
*
|
|
69
|
+
* #### Example:
|
|
70
|
+
* When no other url rule matches, redirect to `home` and provide a `dashboard` parameter value.
|
|
71
|
+
* ```js
|
|
72
|
+
* .otherwise({ state: 'home', params: { dashboard: 'default' } });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* - If `handler` is a function, the function receives the current url ([[UrlParts]]) and the [[UIRouter]] object.
|
|
76
|
+
* The function can perform actions, and/or return a value.
|
|
77
|
+
*
|
|
78
|
+
* #### Example:
|
|
79
|
+
* When no other url rule matches, manually trigger a transition to the `home` state
|
|
80
|
+
* ```js
|
|
81
|
+
* .otherwise((matchValue, urlParts, router) => {
|
|
82
|
+
* router.stateService.go('home');
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* #### Example:
|
|
87
|
+
* When no other url rule matches, go to `home` state
|
|
88
|
+
* ```js
|
|
89
|
+
* .otherwise((matchValue, urlParts, router) => {
|
|
90
|
+
* return { state: 'home' };
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param handler The url path to redirect to, or a function which returns the url path (or performs custom logic).
|
|
95
|
+
*/
|
|
96
|
+
otherwise(handler: any): void;
|
|
97
|
+
_otherwiseFn: any;
|
|
98
|
+
_sorted: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Remove a rule previously registered
|
|
101
|
+
*
|
|
102
|
+
* @param rule the matcher rule that was previously registered using [[rule]]
|
|
103
|
+
*/
|
|
104
|
+
removeRule(rule: any): void;
|
|
105
|
+
/**
|
|
106
|
+
* Manually adds a URL Rule.
|
|
107
|
+
*
|
|
108
|
+
* Usually, a url rule is added using [[StateDeclaration.url]] or [[when]].
|
|
109
|
+
* This api can be used directly for more control (to register a [[BaseUrlRule]], for example).
|
|
110
|
+
* Rules can be created using [[urlRuleFactory]], or created manually as simple objects.
|
|
111
|
+
*
|
|
112
|
+
* A rule should have a `match` function which returns truthy if the rule matched.
|
|
113
|
+
* It should also have a `handler` function which is invoked if the rule is the best match.
|
|
114
|
+
*
|
|
115
|
+
* @return a function that deregisters the rule
|
|
116
|
+
*/
|
|
117
|
+
rule(rule: any): () => void;
|
|
118
|
+
/**
|
|
119
|
+
* Gets all registered rules
|
|
120
|
+
*
|
|
121
|
+
* @returns an array of all the registered rules
|
|
122
|
+
*/
|
|
123
|
+
rules(): any[];
|
|
124
|
+
/**
|
|
125
|
+
* Defines URL Rule priorities
|
|
126
|
+
*
|
|
127
|
+
* More than one rule ([[UrlRule]]) might match a given URL.
|
|
128
|
+
* This `compareFn` is used to sort the rules by priority.
|
|
129
|
+
* Higher priority rules should sort earlier.
|
|
130
|
+
*
|
|
131
|
+
* The [[defaultRuleSortFn]] is used by default.
|
|
132
|
+
*
|
|
133
|
+
* You only need to call this function once.
|
|
134
|
+
* The `compareFn` will be used to sort the rules as each is registered.
|
|
135
|
+
*
|
|
136
|
+
* If called without any parameter, it will re-sort the rules.
|
|
137
|
+
*
|
|
138
|
+
* ---
|
|
139
|
+
*
|
|
140
|
+
* Url rules may come from multiple sources: states's urls ([[StateDeclaration.url]]), [[when]], and [[rule]].
|
|
141
|
+
* Each rule has a (user-provided) [[UrlRule.priority]], a [[UrlRule.type]], and a [[UrlRule.$id]]
|
|
142
|
+
* The `$id` is is the order in which the rule was registered.
|
|
143
|
+
*
|
|
144
|
+
* The sort function should use these data, or data found on a specific type
|
|
145
|
+
* of [[UrlRule]] (such as [[StateRule.state]]), to order the rules as desired.
|
|
146
|
+
*
|
|
147
|
+
* #### Example:
|
|
148
|
+
* This compare function prioritizes rules by the order in which the rules were registered.
|
|
149
|
+
* A rule registered earlier has higher priority.
|
|
150
|
+
*
|
|
151
|
+
* ```js
|
|
152
|
+
* function compareFn(a, b) {
|
|
153
|
+
* return a.$id - b.$id;
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @param compareFn a function that compares to [[UrlRule]] objects.
|
|
158
|
+
* The `compareFn` should abide by the `Array.sort` compare function rules.
|
|
159
|
+
* Given two rules, `a` and `b`, return a negative number if `a` should be higher priority.
|
|
160
|
+
* Return a positive number if `b` should be higher priority.
|
|
161
|
+
* Return `0` if the rules are identical.
|
|
162
|
+
*
|
|
163
|
+
* See the [mozilla reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Description)
|
|
164
|
+
* for details.
|
|
165
|
+
*/
|
|
166
|
+
sort(compareFn: any): void;
|
|
167
|
+
ensureSorted(): void;
|
|
168
|
+
stableSort(arr: any, compareFn: any): any;
|
|
169
|
+
/**
|
|
170
|
+
* Registers a `matcher` and `handler` for custom URLs handling.
|
|
171
|
+
*
|
|
172
|
+
* The `matcher` can be:
|
|
173
|
+
*
|
|
174
|
+
* - a [[UrlMatcher]]: See: [[UrlMatcherFactory.compile]]
|
|
175
|
+
* - a `string`: The string is compiled to a [[UrlMatcher]]
|
|
176
|
+
* - a `RegExp`: The regexp is used to match the url.
|
|
177
|
+
*
|
|
178
|
+
* The `handler` can be:
|
|
179
|
+
*
|
|
180
|
+
* - a string: The url is redirected to the value of the string.
|
|
181
|
+
* - a function: The url is redirected to the return value of the function.
|
|
182
|
+
*
|
|
183
|
+
* ---
|
|
184
|
+
*
|
|
185
|
+
* When the `handler` is a `string` and the `matcher` is a `UrlMatcher` (or string), the redirect
|
|
186
|
+
* string is interpolated with parameter values.
|
|
187
|
+
*
|
|
188
|
+
* #### Example:
|
|
189
|
+
* When the URL is `/foo/123` the rule will redirect to `/bar/123`.
|
|
190
|
+
* ```js
|
|
191
|
+
* .when("/foo/:param1", "/bar/:param1")
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* ---
|
|
195
|
+
*
|
|
196
|
+
* When the `handler` is a string and the `matcher` is a `RegExp`, the redirect string is
|
|
197
|
+
* interpolated with capture groups from the RegExp.
|
|
198
|
+
*
|
|
199
|
+
* #### Example:
|
|
200
|
+
* When the URL is `/foo/123` the rule will redirect to `/bar/123`.
|
|
201
|
+
* ```js
|
|
202
|
+
* .when(new RegExp("^/foo/(.*)$"), "/bar/$1");
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* ---
|
|
206
|
+
*
|
|
207
|
+
* When the handler is a function, it receives the matched value, the current URL, and the `UIRouter` object (See [[UrlRuleHandlerFn]]).
|
|
208
|
+
* The "matched value" differs based on the `matcher`.
|
|
209
|
+
* For [[UrlMatcher]]s, it will be the matched state params.
|
|
210
|
+
* For `RegExp`, it will be the match array from `regexp.exec()`.
|
|
211
|
+
*
|
|
212
|
+
* If the handler returns a string, the URL is redirected to the string.
|
|
213
|
+
*
|
|
214
|
+
* #### Example:
|
|
215
|
+
* When the URL is `/foo/123` the rule will redirect to `/bar/123`.
|
|
216
|
+
* ```js
|
|
217
|
+
* .when(new RegExp("^/foo/(.*)$"), match => "/bar/" + match[1]);
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* Note: the `handler` may also invoke arbitrary code, such as `$state.go()`
|
|
221
|
+
*
|
|
222
|
+
* @param matcher A pattern `string` to match, compiled as a [[UrlMatcher]], or a `RegExp`.
|
|
223
|
+
* @param handler The path to redirect to, or a function that returns the path.
|
|
224
|
+
* @param options `{ priority: number }`
|
|
225
|
+
*
|
|
226
|
+
* @return the registered [[UrlRule]]
|
|
227
|
+
*/
|
|
228
|
+
when(matcher: any, handler: any, options: any): any;
|
|
229
229
|
}
|