@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.
Files changed (151) hide show
  1. package/Makefile +6 -5
  2. package/dist/angular-ts.esm.js +2 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/package.json +2 -4
  5. package/rollup.config.js +5 -1
  6. package/src/core/scope/scope.js +4 -7
  7. package/src/index.js +307 -1
  8. package/src/loader.js +13 -6
  9. package/src/public.js +7 -2
  10. package/src/src.test.js +10 -0
  11. package/tsconfig.json +1 -1
  12. package/tsconfig.types.json +11 -0
  13. package/types/animations/animate-cache.d.ts +7 -7
  14. package/types/animations/animate-children-directive.d.ts +3 -6
  15. package/types/animations/animate-swap.d.ts +7 -16
  16. package/types/animations/animation.d.ts +2 -11
  17. package/types/animations/raf-scheduler.d.ts +3 -3
  18. package/types/animations/shared.d.ts +8 -23
  19. package/types/core/{animate-css.d.ts → animate/animate-css.d.ts} +2 -8
  20. package/types/core/{cache.d.ts → cache/cache.d.ts} +5 -5
  21. package/types/core/compile/compile.d.ts +173 -0
  22. package/types/core/controller/controller.d.ts +32 -0
  23. package/types/core/exception-handler.d.ts +1 -1
  24. package/types/core/filter/filter.d.ts +9 -0
  25. package/types/core/{interpolate.d.ts → interpolate/interpolate.d.ts} +23 -39
  26. package/types/core/interval/interval-factory.d.ts +4 -0
  27. package/types/core/{interval.d.ts → interval/interval.d.ts} +1 -1
  28. package/types/core/location/location.d.ts +209 -0
  29. package/types/core/pubsub/pubsub.d.ts +156 -0
  30. package/types/core/q/q.d.ts +31 -0
  31. package/types/core/sanitize/sanitize-uri.d.ts +53 -0
  32. package/types/core/{sce.d.ts → sce/sce.d.ts} +80 -86
  33. package/types/core/scope/scope.d.ts +727 -0
  34. package/types/core/task-tracker-factory.d.ts +29 -29
  35. package/types/core/timeout/timeout.d.ts +20 -0
  36. package/types/core/{urlUtils.d.ts → url-utils/url-utils.d.ts} +2 -7
  37. package/types/directive/{bind.d.ts → bind/bind.d.ts} +4 -10
  38. package/types/directive/{class.d.ts → class/class.d.ts} +12 -21
  39. package/types/directive/controller/controller.d.ts +6 -0
  40. package/types/directive/events/events.d.ts +5 -0
  41. package/types/directive/form/form.d.ts +200 -0
  42. package/types/directive/if/if.d.ts +8 -0
  43. package/types/directive/include/include.d.ts +14 -0
  44. package/types/directive/{input.d.ts → input/input.d.ts} +20 -69
  45. package/types/directive/{model.d.ts → model/model.d.ts} +256 -279
  46. package/types/directive/options/options.d.ts +9 -0
  47. package/types/directive/ref/ref.d.ts +5 -0
  48. package/types/directive/repeat/repeat.d.ts +8 -0
  49. package/types/directive/{script.d.ts → script/script.d.ts} +5 -8
  50. package/types/directive/{show-hide.d.ts → show-hide/show-hide.d.ts} +10 -16
  51. package/types/directive/switch/switch.d.ts +17 -0
  52. package/types/directive/transclude/transclude.d.ts +4 -0
  53. package/types/directive/{validators.d.ts → validators/validators.d.ts} +20 -35
  54. package/types/filters/filters.d.ts +10 -16
  55. package/types/filters/order-by.d.ts +2 -4
  56. package/types/index.d.ts +117 -0
  57. package/types/injector.d.ts +12 -0
  58. package/types/public.d.ts +5 -0
  59. package/types/router/common/coreservices.d.ts +2 -2
  60. package/types/router/common/glob.d.ts +9 -9
  61. package/types/router/common/queue.d.ts +13 -13
  62. package/types/router/common/trace.d.ts +43 -43
  63. package/types/router/directives/view-directive.d.ts +13 -32
  64. package/types/router/globals.d.ts +20 -20
  65. package/types/router/hooks/lazy-load.d.ts +2 -11
  66. package/types/router/hooks/redirect-to.d.ts +1 -4
  67. package/types/router/hooks/url.d.ts +1 -5
  68. package/types/router/hooks/views.d.ts +1 -4
  69. package/types/router/params/param-factory.d.ts +5 -5
  70. package/types/router/params/param-type.d.ts +35 -35
  71. package/types/router/params/param-types.d.ts +11 -11
  72. package/types/router/params/param.d.ts +38 -38
  73. package/types/router/params/state-params.d.ts +10 -10
  74. package/types/router/path/path-node.d.ts +34 -34
  75. package/types/router/path/path-utils.d.ts +73 -77
  76. package/types/router/resolve/resolvable.d.ts +32 -32
  77. package/types/router/resolve/resolve-context.d.ts +84 -84
  78. package/types/router/services.d.ts +4 -9
  79. package/types/router/state/state-builder.d.ts +27 -27
  80. package/types/router/state/state-matcher.d.ts +5 -5
  81. package/types/router/state/state-object.d.ts +58 -58
  82. package/types/router/state/state-queue-manager.d.ts +10 -16
  83. package/types/router/state/state-registry.d.ts +100 -107
  84. package/types/router/state/state-service.d.ts +411 -411
  85. package/types/router/state/target-state.d.ts +64 -69
  86. package/types/router/state/views.d.ts +31 -37
  87. package/types/router/state-filters.d.ts +7 -7
  88. package/types/router/state-provider.d.ts +105 -105
  89. package/types/router/template-factory.d.ts +83 -112
  90. package/types/router/transition/hook-builder.d.ts +25 -25
  91. package/types/router/transition/hook-registry.d.ts +68 -83
  92. package/types/router/transition/interface.d.ts +7 -7
  93. package/types/router/transition/reject-factory.d.ts +34 -34
  94. package/types/router/transition/transition-event-type.d.ts +9 -18
  95. package/types/router/transition/transition-hook.d.ts +77 -82
  96. package/types/router/transition/transition-service.d.ts +82 -99
  97. package/types/router/transition/transition.d.ts +369 -377
  98. package/types/router/url/url-config.d.ts +84 -84
  99. package/types/router/url/url-matcher.d.ts +115 -119
  100. package/types/router/url/url-rule.d.ts +114 -124
  101. package/types/router/url/url-rules.d.ts +217 -217
  102. package/types/router/url/url-service.d.ts +264 -269
  103. package/types/router/view/view.d.ts +114 -117
  104. package/types/router/view-scroll.d.ts +2 -2
  105. package/types/services/anchor-scroll.d.ts +2 -8
  106. package/types/services/browser.d.ts +122 -130
  107. package/types/services/cache-factory.d.ts +25 -25
  108. package/types/services/cookie-reader.d.ts +2 -2
  109. package/types/services/document.d.ts +2 -2
  110. package/types/services/http/http.d.ts +145 -0
  111. package/types/services/{http-backend.d.ts → http-backend/http-backend.d.ts} +3 -35
  112. package/types/services/log.d.ts +49 -49
  113. package/types/services/template-request.d.ts +44 -53
  114. package/types/shared/common.d.ts +4 -19
  115. package/types/{constants.d.ts → shared/constants.d.ts} +6 -6
  116. package/types/shared/hof.d.ts +1 -1
  117. package/types/{jqLite.d.ts → shared/jqlite/jqlite.d.ts} +11 -11
  118. package/types/shared/test-utils.d.ts +11 -0
  119. package/types/shared/utils.d.ts +7 -24
  120. package/types-back/global.d.ts +3 -1
  121. package/types-back/index.d.ts +2 -221
  122. package/types/core/compile.d.ts +0 -206
  123. package/types/core/controller.d.ts +0 -42
  124. package/types/core/filter.d.ts +0 -9
  125. package/types/core/interval-factory.d.ts +0 -21
  126. package/types/core/location.d.ts +0 -234
  127. package/types/core/pubsub.d.ts +0 -164
  128. package/types/core/q.d.ts +0 -33
  129. package/types/core/root-scope.d.ts +0 -754
  130. package/types/core/sanitize-uri.d.ts +0 -57
  131. package/types/core/timeout.d.ts +0 -31
  132. package/types/directive/controller.d.ts +0 -6
  133. package/types/directive/events.d.ts +0 -12
  134. package/types/directive/form.d.ts +0 -230
  135. package/types/directive/if.d.ts +0 -17
  136. package/types/directive/include.d.ts +0 -33
  137. package/types/directive/options.d.ts +0 -16
  138. package/types/directive/ref.d.ts +0 -11
  139. package/types/directive/repeat.d.ts +0 -23
  140. package/types/directive/switch.d.ts +0 -23
  141. package/types/directive/transclude.d.ts +0 -15
  142. package/types/services/http.d.ts +0 -157
  143. /package/types/directive/{attrs.d.ts → attrs/attrs.d.ts} +0 -0
  144. /package/types/directive/{change.d.ts → change/change.d.ts} +0 -0
  145. /package/types/directive/{cloak.d.ts → cloak/cloak.d.ts} +0 -0
  146. /package/types/directive/{init.d.ts → init/init.d.ts} +0 -0
  147. /package/types/directive/{list.d.ts → list/list.d.ts} +0 -0
  148. /package/types/directive/{non-bindable.d.ts → non-bindable/non-bindable.d.ts} +0 -0
  149. /package/types/directive/{style.d.ts → style/style.d.ts} +0 -0
  150. /package/types/exts/{aria.d.ts → aria/aria.d.ts} +0 -0
  151. /package/types/exts/{messages.d.ts → messages/messages.d.ts} +0 -0
@@ -4,416 +4,416 @@
4
4
  * This API is located at `router.stateService` ([[UIRouter.stateService]])
5
5
  */
6
6
  export class StateService {
7
- static $inject: string[];
8
- constructor(globals: any, transitionService: any);
9
- /**
10
- * The latest successful state parameters
11
- *
12
- * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
13
- */
14
- get params(): any;
15
- /**
16
- * The current [[StateDeclaration]]
17
- *
18
- * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
19
- */
20
- get current(): any;
21
- /**
22
- * The current [[StateObject]] (an internal API)
23
- *
24
- * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
25
- */
26
- get $current(): any;
27
- stateRegistry: any;
28
- urlService: any;
29
- globals: any;
30
- transitionService: any;
31
- invalidCallbacks: any[];
32
- _defaultErrorHandler: ($error$: any) => never;
33
- $get: (() => this)[];
34
- /**
35
- * Decorates states when they are registered
36
- *
37
- * Allows you to extend (carefully) or override (at your own peril) the
38
- * `stateBuilder` object used internally by [[StateRegistry]].
39
- * This can be used to add custom functionality to ui-router,
40
- * for example inferring templateUrl based on the state name.
41
- *
42
- * When passing only a name, it returns the current (original or decorated) builder
43
- * function that matches `name`.
44
- *
45
- * The builder functions that can be decorated are listed below. Though not all
46
- * necessarily have a good use case for decoration, that is up to you to decide.
47
- *
48
- * In addition, users can attach custom decorators, which will generate new
49
- * properties within the state's internal definition. There is currently no clear
50
- * use-case for this beyond accessing internal states (i.e. $state.$current),
51
- * however, expect this to become increasingly relevant as we introduce additional
52
- * meta-programming features.
53
- *
54
- * **Warning**: Decorators should not be interdependent because the order of
55
- * execution of the builder functions in non-deterministic. Builder functions
56
- * should only be dependent on the state definition object and super function.
57
- *
58
- *
59
- * Existing builder functions and current return values:
60
- *
61
- * - **parent** `{object}` - returns the parent state object.
62
- * - **data** `{object}` - returns state data, including any inherited data that is not
63
- * overridden by own values (if any).
64
- * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
65
- * or `null`.
66
- * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
67
- * navigable).
68
- * - **params** `{object}` - returns an array of state params that are ensured to
69
- * be a super-set of parent's params.
70
- * - **views** `{object}` - returns a views object where each key is an absolute view
71
- * name (i.e. "viewName@stateName") and each value is the config object
72
- * (template, controller) for the view. Even when you don't use the views object
73
- * explicitly on a state config, one is still created for you internally.
74
- * So by decorating this builder function you have access to decorating template
75
- * and controller properties.
76
- * - **ownParams** `{object}` - returns an array of params that belong to the state,
77
- * not including any params defined by ancestor states.
78
- * - **path** `{string}` - returns the full path from the root down to this state.
79
- * Needed for state activation.
80
- * - **includes** `{object}` - returns an object that includes every state that
81
- * would pass a `$state.includes()` test.
82
- *
83
- * #### Example:
84
- * Override the internal 'views' builder with a function that takes the state
85
- * definition, and a reference to the internal function being overridden:
86
- * ```js
87
- * $stateProvider.decorator('views', function (state, parent) {
88
- * let result = {},
89
- * views = parent(state);
90
- *
91
- * angular.forEach(views, function (config, name) {
92
- * let autoName = (state.name + '.' + name).replace('.', '/');
93
- * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
94
- * result[name] = config;
95
- * });
96
- * return result;
97
- * });
98
- *
99
- * $stateProvider.state('home', {
100
- * views: {
101
- * 'contact.list': { controller: 'ListController' },
102
- * 'contact.item': { controller: 'ItemController' }
103
- * }
104
- * });
105
- * ```
106
- *
107
- *
108
- * ```js
109
- * // Auto-populates list and item views with /partials/home/contact/list.html,
110
- * // and /partials/home/contact/item.html, respectively.
111
- * $state.go('home');
112
- * ```
113
- *
114
- * @param {string} name The name of the builder function to decorate.
115
- * @param {object} func A function that is responsible for decorating the original
116
- * builder function. The function receives two parameters:
117
- *
118
- * - `{object}` - state - The state config object.
119
- * - `{object}` - super - The original builder function.
120
- *
121
- * @return {object} $stateProvider - $stateProvider instance
122
- */
123
- decorator(name: string, func: object): object;
124
- /**
125
- *
126
- * @param {angular.Ng1StateDeclaration} definition
127
- */
128
- state(definition: angular.Ng1StateDeclaration): this;
129
- /**
130
- * Registers an invalid state handler
131
- *
132
- * This is a passthrough to [[StateService.onInvalid]] for ng1.
133
- */
134
- onInvalid(callback: any): any;
135
- /**
136
- * Registers an Invalid State handler
137
- *
138
- * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
139
- * has been called with an invalid state reference parameter
140
- *
141
- * Example:
142
- * ```js
143
- * stateService.onInvalid(function(to, from, injector) {
144
- * if (to.name() === 'foo') {
145
- * let lazyLoader = injector.get('LazyLoadService');
146
- * return lazyLoader.load('foo')
147
- * .then(() => stateService.target('foo'));
148
- * }
149
- * });
150
- * ```
151
- *
152
- * @param {function} callback invoked when the toState is invalid
153
- * This function receives the (invalid) toState, the fromState, and an injector.
154
- * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
155
- * If one is returned, it is treated as a redirect.
156
- *
157
- * @returns a function which deregisters the callback
158
- */
159
- onInvalid(callback: Function): any;
160
- /**
161
- * Handler for when [[transitionTo]] is called with an invalid state.
162
- *
163
- * Invokes the [[onInvalid]] callbacks, in natural order.
164
- * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
165
- * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
166
- *
167
- * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
168
- *
169
- * @internal
170
- */
171
- _handleInvalidTargetState(fromPath: any, toState: any): any;
172
- /**
173
- * Reloads the current state
174
- *
175
- * A method that force reloads the current state, or a partial state hierarchy.
176
- * All resolves are re-resolved, and components reinstantiated.
177
- *
178
- * #### Example:
179
- * ```js
180
- * let app angular.module('app', ['ui.router']);
181
- *
182
- * app.controller('ctrl', function ($scope, $state) {
183
- * $scope.reload = function(){
184
- * $state.reload();
185
- * }
186
- * });
187
- * ```
188
- *
189
- * Note: `reload()` is just an alias for:
190
- *
191
- * ```js
192
- * $state.transitionTo($state.current, $state.params, {
193
- * reload: true, inherit: false
194
- * });
195
- * ```
196
- *
197
- * @param reloadState A state name or a state object.
198
- * If present, this state and all its children will be reloaded, but ancestors will not reload.
199
- *
200
- * #### Example:
201
- * ```js
202
- * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
203
- * //and current state is 'contacts.detail.item'
204
- * let app angular.module('app', ['ui.router']);
205
- *
206
- * app.controller('ctrl', function ($scope, $state) {
207
- * $scope.reload = function(){
208
- * //will reload 'contact.detail' and nested 'contact.detail.item' states
209
- * $state.reload('contact.detail');
210
- * }
211
- * });
212
- * ```
213
- *
214
- * @returns A promise representing the state of the new transition. See [[StateService.go]]
215
- */
216
- reload(reloadState: any): any;
217
- /**
218
- * Transition to a different state and/or parameters
219
- *
220
- * Convenience method for transitioning to a new state.
221
- *
222
- * `$state.go` calls `$state.transitionTo` internally but automatically sets options to
223
- * `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
224
- * This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
225
- * It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
226
- * inherit from the current parameter values (because of `inherit: true`).
227
- *
228
- * #### Example:
229
- * ```js
230
- * let app = angular.module('app', ['ui.router']);
231
- *
232
- * app.controller('ctrl', function ($scope, $state) {
233
- * $scope.changeState = function () {
234
- * $state.go('contact.detail');
235
- * };
236
- * });
237
- * ```
238
- *
239
- * @param to Absolute state name, state object, or relative state path (relative to current state).
240
- *
241
- * Some examples:
242
- *
243
- * - `$state.go('contact.detail')` - will go to the `contact.detail` state
244
- * - `$state.go('^')` - will go to the parent state
245
- * - `$state.go('^.sibling')` - if current state is `home.child`, will go to the `home.sibling` state
246
- * - `$state.go('.child.grandchild')` - if current state is home, will go to the `home.child.grandchild` state
247
- *
248
- * @param params A map of the parameters that will be sent to the state, will populate $stateParams.
249
- *
250
- * Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
251
- * This allows, for example, going to a sibling state that shares parameters defined by a parent state.
252
- *
253
- * @param options Transition options
254
- *
255
- * @returns {promise} A promise representing the state of the new transition.
256
- */
257
- go(to: any, params: any, options: any): Promise<any>;
258
- /**
259
- * Creates a [[TargetState]]
260
- *
261
- * This is a factory method for creating a TargetState
262
- *
263
- * This may be returned from a Transition Hook to redirect a transition, for example.
264
- */
265
- target(identifier: any, params: any, options?: {}): TargetState;
266
- getCurrentPath(): any;
267
- /**
268
- * Low-level method for transitioning to a new state.
269
- *
270
- * The [[go]] method (which uses `transitionTo` internally) is recommended in most situations.
271
- *
272
- * #### Example:
273
- * ```js
274
- * let app = angular.module('app', ['ui.router']);
275
- *
276
- * app.controller('ctrl', function ($scope, $state) {
277
- * $scope.changeState = function () {
278
- * $state.transitionTo('contact.detail');
279
- * };
280
- * });
281
- * ```
282
- *
283
- * @param to State name or state object.
284
- * @param toParams A map of the parameters that will be sent to the state,
285
- * will populate $stateParams.
286
- * @param options Transition options
287
- *
288
- * @returns A promise representing the state of the new transition. See [[go]]
289
- */
290
- transitionTo(to: any, toParams?: {}, options?: {}): any;
291
- /**
292
- * Checks if the current state *is* the provided state
293
- *
294
- * Similar to [[includes]] but only checks for the full state name.
295
- * If params is supplied then it will be tested for strict equality against the current
296
- * active params object, so all params must match with none missing and no extras.
297
- *
298
- * #### Example:
299
- * ```js
300
- * $state.$current.name = 'contacts.details.item';
301
- *
302
- * // absolute name
303
- * $state.is('contact.details.item'); // returns true
304
- * $state.is(contactDetailItemStateObject); // returns true
305
- * ```
306
- *
307
- * // relative name (. and ^), typically from a template
308
- * // E.g. from the 'contacts.details' template
309
- * ```html
310
- * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
311
- * ```
312
- *
313
- * @param stateOrName The state name (absolute or relative) or state object you'd like to check.
314
- * @param params A param object, e.g. `{sectionId: section.id}`, that you'd like
315
- * to test against the current active state.
316
- * @param options An options object. The options are:
317
- * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
318
- * test relative to `options.relative` state (or name).
319
- *
320
- * @returns Returns true if it is the state.
321
- */
322
- is(stateOrName: any, params: any, options: any): boolean;
323
- /**
324
- * Checks if the current state *includes* the provided state
325
- *
326
- * A method to determine if the current active state is equal to or is the child of the
327
- * state stateName. If any params are passed then they will be tested for a match as well.
328
- * Not all the parameters need to be passed, just the ones you'd like to test for equality.
329
- *
330
- * #### Example when `$state.$current.name === 'contacts.details.item'`
331
- * ```js
332
- * // Using partial names
333
- * $state.includes("contacts"); // returns true
334
- * $state.includes("contacts.details"); // returns true
335
- * $state.includes("contacts.details.item"); // returns true
336
- * $state.includes("contacts.list"); // returns false
337
- * $state.includes("about"); // returns false
338
- * ```
339
- *
340
- * #### Glob Examples when `* $state.$current.name === 'contacts.details.item.url'`:
341
- * ```js
342
- * $state.includes("*.details.*.*"); // returns true
343
- * $state.includes("*.details.**"); // returns true
344
- * $state.includes("**.item.**"); // returns true
345
- * $state.includes("*.details.item.url"); // returns true
346
- * $state.includes("*.details.*.url"); // returns true
347
- * $state.includes("*.details.*"); // returns false
348
- * $state.includes("item.**"); // returns false
349
- * ```
350
- *
351
- * @param stateOrName A partial name, relative name, glob pattern,
352
- * or state object to be searched for within the current state name.
353
- * @param params A param object, e.g. `{sectionId: section.id}`,
354
- * that you'd like to test against the current active state.
355
- * @param options An options object. The options are:
356
- * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
357
- * test relative to `options.relative` state (or name).
358
- *
359
- * @returns {boolean} Returns true if it does include the state
360
- */
361
- includes(stateOrName: any, params: any, options: any): boolean;
362
- /**
363
- * Generates a URL for a state and parameters
364
- *
365
- * Returns the url for the given state populated with the given params.
366
- *
367
- * #### Example:
368
- * ```js
369
- * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
370
- * ```
371
- *
372
- * @param stateOrName The state name or state object you'd like to generate a url from.
373
- * @param params An object of parameter values to fill the state's required parameters.
374
- * @param options Options object. The options are:
375
- *
376
- * @returns {string} compiled state url
377
- */
378
- href(stateOrName: any, params: any, options: any): string;
379
- /**
380
- * Sets or gets the default [[transitionTo]] error handler.
381
- *
382
- * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
383
- * This includes errors caused by resolves and transition hooks.
384
- *
385
- * Note:
386
- * This handler does not receive certain Transition rejections.
387
- * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
388
- *
389
- * The built-in default error handler logs the error to the console.
390
- *
391
- * You can provide your own custom handler.
392
- *
393
- * #### Example:
394
- * ```js
395
- * stateService.defaultErrorHandler(function() {
396
- * // Do not log transitionTo errors
397
- * });
398
- * ```
399
- *
400
- * @param handler a global error handler function
401
- * @returns the current global error handler
402
- */
403
- defaultErrorHandler(handler: any): any;
404
- get(stateOrName: any, base: any, ...args: any[]): any;
405
- /**
406
- * Lazy loads a state
407
- *
408
- * Explicitly runs a state's [[StateDeclaration.lazyLoad]] function.
409
- *
410
- * @param stateOrName the state that should be lazy loaded
411
- * @param transition the optional Transition context to use (if the lazyLoad function requires an injector, etc)
412
- * Note: If no transition is provided, a noop transition is created using the from the current state to the current state.
413
- * This noop transition is not actually run.
414
- *
415
- * @returns a promise to lazy load
416
- */
417
- lazyLoad(stateOrName: any, transition: any): any;
7
+ static $inject: string[];
8
+ constructor(globals: any, transitionService: any);
9
+ /**
10
+ * The latest successful state parameters
11
+ *
12
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
13
+ */
14
+ get params(): any;
15
+ /**
16
+ * The current [[StateDeclaration]]
17
+ *
18
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
19
+ */
20
+ get current(): any;
21
+ /**
22
+ * The current [[StateObject]] (an internal API)
23
+ *
24
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
25
+ */
26
+ get $current(): any;
27
+ stateRegistry: any;
28
+ urlService: any;
29
+ globals: any;
30
+ transitionService: any;
31
+ invalidCallbacks: any[];
32
+ _defaultErrorHandler: ($error$: any) => never;
33
+ $get: (() => this)[];
34
+ /**
35
+ * Decorates states when they are registered
36
+ *
37
+ * Allows you to extend (carefully) or override (at your own peril) the
38
+ * `stateBuilder` object used internally by [[StateRegistry]].
39
+ * This can be used to add custom functionality to ui-router,
40
+ * for example inferring templateUrl based on the state name.
41
+ *
42
+ * When passing only a name, it returns the current (original or decorated) builder
43
+ * function that matches `name`.
44
+ *
45
+ * The builder functions that can be decorated are listed below. Though not all
46
+ * necessarily have a good use case for decoration, that is up to you to decide.
47
+ *
48
+ * In addition, users can attach custom decorators, which will generate new
49
+ * properties within the state's internal definition. There is currently no clear
50
+ * use-case for this beyond accessing internal states (i.e. $state.$current),
51
+ * however, expect this to become increasingly relevant as we introduce additional
52
+ * meta-programming features.
53
+ *
54
+ * **Warning**: Decorators should not be interdependent because the order of
55
+ * execution of the builder functions in non-deterministic. Builder functions
56
+ * should only be dependent on the state definition object and super function.
57
+ *
58
+ *
59
+ * Existing builder functions and current return values:
60
+ *
61
+ * - **parent** `{object}` - returns the parent state object.
62
+ * - **data** `{object}` - returns state data, including any inherited data that is not
63
+ * overridden by own values (if any).
64
+ * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
65
+ * or `null`.
66
+ * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
67
+ * navigable).
68
+ * - **params** `{object}` - returns an array of state params that are ensured to
69
+ * be a super-set of parent's params.
70
+ * - **views** `{object}` - returns a views object where each key is an absolute view
71
+ * name (i.e. "viewName@stateName") and each value is the config object
72
+ * (template, controller) for the view. Even when you don't use the views object
73
+ * explicitly on a state config, one is still created for you internally.
74
+ * So by decorating this builder function you have access to decorating template
75
+ * and controller properties.
76
+ * - **ownParams** `{object}` - returns an array of params that belong to the state,
77
+ * not including any params defined by ancestor states.
78
+ * - **path** `{string}` - returns the full path from the root down to this state.
79
+ * Needed for state activation.
80
+ * - **includes** `{object}` - returns an object that includes every state that
81
+ * would pass a `$state.includes()` test.
82
+ *
83
+ * #### Example:
84
+ * Override the internal 'views' builder with a function that takes the state
85
+ * definition, and a reference to the internal function being overridden:
86
+ * ```js
87
+ * $stateProvider.decorator('views', function (state, parent) {
88
+ * let result = {},
89
+ * views = parent(state);
90
+ *
91
+ * angular.forEach(views, function (config, name) {
92
+ * let autoName = (state.name + '.' + name).replace('.', '/');
93
+ * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
94
+ * result[name] = config;
95
+ * });
96
+ * return result;
97
+ * });
98
+ *
99
+ * $stateProvider.state('home', {
100
+ * views: {
101
+ * 'contact.list': { controller: 'ListController' },
102
+ * 'contact.item': { controller: 'ItemController' }
103
+ * }
104
+ * });
105
+ * ```
106
+ *
107
+ *
108
+ * ```js
109
+ * // Auto-populates list and item views with /partials/home/contact/list.html,
110
+ * // and /partials/home/contact/item.html, respectively.
111
+ * $state.go('home');
112
+ * ```
113
+ *
114
+ * @param {string} name The name of the builder function to decorate.
115
+ * @param {object} func A function that is responsible for decorating the original
116
+ * builder function. The function receives two parameters:
117
+ *
118
+ * - `{object}` - state - The state config object.
119
+ * - `{object}` - super - The original builder function.
120
+ *
121
+ * @return {object} $stateProvider - $stateProvider instance
122
+ */
123
+ decorator(name: string, func: object): object;
124
+ /**
125
+ *
126
+ * @param {angular.Ng1StateDeclaration} definition
127
+ */
128
+ state(definition: angular.Ng1StateDeclaration): this;
129
+ /**
130
+ * Registers an invalid state handler
131
+ *
132
+ * This is a passthrough to [[StateService.onInvalid]] for ng1.
133
+ */
134
+ onInvalid(callback: any): any;
135
+ /**
136
+ * Registers an Invalid State handler
137
+ *
138
+ * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
139
+ * has been called with an invalid state reference parameter
140
+ *
141
+ * Example:
142
+ * ```js
143
+ * stateService.onInvalid(function(to, from, injector) {
144
+ * if (to.name() === 'foo') {
145
+ * let lazyLoader = injector.get('LazyLoadService');
146
+ * return lazyLoader.load('foo')
147
+ * .then(() => stateService.target('foo'));
148
+ * }
149
+ * });
150
+ * ```
151
+ *
152
+ * @param {function} callback invoked when the toState is invalid
153
+ * This function receives the (invalid) toState, the fromState, and an injector.
154
+ * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
155
+ * If one is returned, it is treated as a redirect.
156
+ *
157
+ * @returns a function which deregisters the callback
158
+ */
159
+ onInvalid(callback: Function): any;
160
+ /**
161
+ * Handler for when [[transitionTo]] is called with an invalid state.
162
+ *
163
+ * Invokes the [[onInvalid]] callbacks, in natural order.
164
+ * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
165
+ * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
166
+ *
167
+ * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
168
+ *
169
+ * @internal
170
+ */
171
+ _handleInvalidTargetState(fromPath: any, toState: any): any;
172
+ /**
173
+ * Reloads the current state
174
+ *
175
+ * A method that force reloads the current state, or a partial state hierarchy.
176
+ * All resolves are re-resolved, and components reinstantiated.
177
+ *
178
+ * #### Example:
179
+ * ```js
180
+ * let app angular.module('app', ['ui.router']);
181
+ *
182
+ * app.controller('ctrl', function ($scope, $state) {
183
+ * $scope.reload = function(){
184
+ * $state.reload();
185
+ * }
186
+ * });
187
+ * ```
188
+ *
189
+ * Note: `reload()` is just an alias for:
190
+ *
191
+ * ```js
192
+ * $state.transitionTo($state.current, $state.params, {
193
+ * reload: true, inherit: false
194
+ * });
195
+ * ```
196
+ *
197
+ * @param reloadState A state name or a state object.
198
+ * If present, this state and all its children will be reloaded, but ancestors will not reload.
199
+ *
200
+ * #### Example:
201
+ * ```js
202
+ * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
203
+ * //and current state is 'contacts.detail.item'
204
+ * let app angular.module('app', ['ui.router']);
205
+ *
206
+ * app.controller('ctrl', function ($scope, $state) {
207
+ * $scope.reload = function(){
208
+ * //will reload 'contact.detail' and nested 'contact.detail.item' states
209
+ * $state.reload('contact.detail');
210
+ * }
211
+ * });
212
+ * ```
213
+ *
214
+ * @returns A promise representing the state of the new transition. See [[StateService.go]]
215
+ */
216
+ reload(reloadState: any): any;
217
+ /**
218
+ * Transition to a different state and/or parameters
219
+ *
220
+ * Convenience method for transitioning to a new state.
221
+ *
222
+ * `$state.go` calls `$state.transitionTo` internally but automatically sets options to
223
+ * `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
224
+ * This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
225
+ * It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
226
+ * inherit from the current parameter values (because of `inherit: true`).
227
+ *
228
+ * #### Example:
229
+ * ```js
230
+ * let app = angular.module('app', ['ui.router']);
231
+ *
232
+ * app.controller('ctrl', function ($scope, $state) {
233
+ * $scope.changeState = function () {
234
+ * $state.go('contact.detail');
235
+ * };
236
+ * });
237
+ * ```
238
+ *
239
+ * @param to Absolute state name, state object, or relative state path (relative to current state).
240
+ *
241
+ * Some examples:
242
+ *
243
+ * - `$state.go('contact.detail')` - will go to the `contact.detail` state
244
+ * - `$state.go('^')` - will go to the parent state
245
+ * - `$state.go('^.sibling')` - if current state is `home.child`, will go to the `home.sibling` state
246
+ * - `$state.go('.child.grandchild')` - if current state is home, will go to the `home.child.grandchild` state
247
+ *
248
+ * @param params A map of the parameters that will be sent to the state, will populate $stateParams.
249
+ *
250
+ * Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
251
+ * This allows, for example, going to a sibling state that shares parameters defined by a parent state.
252
+ *
253
+ * @param options Transition options
254
+ *
255
+ * @returns {promise} A promise representing the state of the new transition.
256
+ */
257
+ go(to: any, params: any, options: any): Promise<any>;
258
+ /**
259
+ * Creates a [[TargetState]]
260
+ *
261
+ * This is a factory method for creating a TargetState
262
+ *
263
+ * This may be returned from a Transition Hook to redirect a transition, for example.
264
+ */
265
+ target(identifier: any, params: any, options?: {}): TargetState;
266
+ getCurrentPath(): any;
267
+ /**
268
+ * Low-level method for transitioning to a new state.
269
+ *
270
+ * The [[go]] method (which uses `transitionTo` internally) is recommended in most situations.
271
+ *
272
+ * #### Example:
273
+ * ```js
274
+ * let app = angular.module('app', ['ui.router']);
275
+ *
276
+ * app.controller('ctrl', function ($scope, $state) {
277
+ * $scope.changeState = function () {
278
+ * $state.transitionTo('contact.detail');
279
+ * };
280
+ * });
281
+ * ```
282
+ *
283
+ * @param to State name or state object.
284
+ * @param toParams A map of the parameters that will be sent to the state,
285
+ * will populate $stateParams.
286
+ * @param options Transition options
287
+ *
288
+ * @returns A promise representing the state of the new transition. See [[go]]
289
+ */
290
+ transitionTo(to: any, toParams?: {}, options?: {}): any;
291
+ /**
292
+ * Checks if the current state *is* the provided state
293
+ *
294
+ * Similar to [[includes]] but only checks for the full state name.
295
+ * If params is supplied then it will be tested for strict equality against the current
296
+ * active params object, so all params must match with none missing and no extras.
297
+ *
298
+ * #### Example:
299
+ * ```js
300
+ * $state.$current.name = 'contacts.details.item';
301
+ *
302
+ * // absolute name
303
+ * $state.is('contact.details.item'); // returns true
304
+ * $state.is(contactDetailItemStateObject); // returns true
305
+ * ```
306
+ *
307
+ * // relative name (. and ^), typically from a template
308
+ * // E.g. from the 'contacts.details' template
309
+ * ```html
310
+ * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
311
+ * ```
312
+ *
313
+ * @param stateOrName The state name (absolute or relative) or state object you'd like to check.
314
+ * @param params A param object, e.g. `{sectionId: section.id}`, that you'd like
315
+ * to test against the current active state.
316
+ * @param options An options object. The options are:
317
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
318
+ * test relative to `options.relative` state (or name).
319
+ *
320
+ * @returns Returns true if it is the state.
321
+ */
322
+ is(stateOrName: any, params: any, options: any): boolean;
323
+ /**
324
+ * Checks if the current state *includes* the provided state
325
+ *
326
+ * A method to determine if the current active state is equal to or is the child of the
327
+ * state stateName. If any params are passed then they will be tested for a match as well.
328
+ * Not all the parameters need to be passed, just the ones you'd like to test for equality.
329
+ *
330
+ * #### Example when `$state.$current.name === 'contacts.details.item'`
331
+ * ```js
332
+ * // Using partial names
333
+ * $state.includes("contacts"); // returns true
334
+ * $state.includes("contacts.details"); // returns true
335
+ * $state.includes("contacts.details.item"); // returns true
336
+ * $state.includes("contacts.list"); // returns false
337
+ * $state.includes("about"); // returns false
338
+ * ```
339
+ *
340
+ * #### Glob Examples when `* $state.$current.name === 'contacts.details.item.url'`:
341
+ * ```js
342
+ * $state.includes("*.details.*.*"); // returns true
343
+ * $state.includes("*.details.**"); // returns true
344
+ * $state.includes("**.item.**"); // returns true
345
+ * $state.includes("*.details.item.url"); // returns true
346
+ * $state.includes("*.details.*.url"); // returns true
347
+ * $state.includes("*.details.*"); // returns false
348
+ * $state.includes("item.**"); // returns false
349
+ * ```
350
+ *
351
+ * @param stateOrName A partial name, relative name, glob pattern,
352
+ * or state object to be searched for within the current state name.
353
+ * @param params A param object, e.g. `{sectionId: section.id}`,
354
+ * that you'd like to test against the current active state.
355
+ * @param options An options object. The options are:
356
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
357
+ * test relative to `options.relative` state (or name).
358
+ *
359
+ * @returns {boolean} Returns true if it does include the state
360
+ */
361
+ includes(stateOrName: any, params: any, options: any): boolean;
362
+ /**
363
+ * Generates a URL for a state and parameters
364
+ *
365
+ * Returns the url for the given state populated with the given params.
366
+ *
367
+ * #### Example:
368
+ * ```js
369
+ * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
370
+ * ```
371
+ *
372
+ * @param stateOrName The state name or state object you'd like to generate a url from.
373
+ * @param params An object of parameter values to fill the state's required parameters.
374
+ * @param options Options object. The options are:
375
+ *
376
+ * @returns {string} compiled state url
377
+ */
378
+ href(stateOrName: any, params: any, options: any): string;
379
+ /**
380
+ * Sets or gets the default [[transitionTo]] error handler.
381
+ *
382
+ * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
383
+ * This includes errors caused by resolves and transition hooks.
384
+ *
385
+ * Note:
386
+ * This handler does not receive certain Transition rejections.
387
+ * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
388
+ *
389
+ * The built-in default error handler logs the error to the console.
390
+ *
391
+ * You can provide your own custom handler.
392
+ *
393
+ * #### Example:
394
+ * ```js
395
+ * stateService.defaultErrorHandler(function() {
396
+ * // Do not log transitionTo errors
397
+ * });
398
+ * ```
399
+ *
400
+ * @param handler a global error handler function
401
+ * @returns the current global error handler
402
+ */
403
+ defaultErrorHandler(handler: any): any;
404
+ get(stateOrName: any, base: any, ...args: any[]): any;
405
+ /**
406
+ * Lazy loads a state
407
+ *
408
+ * Explicitly runs a state's [[StateDeclaration.lazyLoad]] function.
409
+ *
410
+ * @param stateOrName the state that should be lazy loaded
411
+ * @param transition the optional Transition context to use (if the lazyLoad function requires an injector, etc)
412
+ * Note: If no transition is provided, a noop transition is created using the from the current state to the current state.
413
+ * This noop transition is not actually run.
414
+ *
415
+ * @returns a promise to lazy load
416
+ */
417
+ lazyLoad(stateOrName: any, transition: any): any;
418
418
  }
419
419
  import { TargetState } from "./target-state";