@angular-wave/angular.ts 0.0.21 → 0.0.23

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 (134) hide show
  1. package/Makefile +1 -1
  2. package/TODO.md +14 -0
  3. package/dist/angular-ts.esm.js +1 -1
  4. package/dist/angular-ts.umd.js +1 -1
  5. package/index.html +8 -2
  6. package/package.json +1 -1
  7. package/src/animations/animate-css-driver.js +2 -2
  8. package/src/animations/animate-css.js +15 -6
  9. package/src/animations/animate-js.js +1 -1
  10. package/src/animations/animate-queue.js +1 -1
  11. package/src/animations/shared.js +0 -14
  12. package/src/core/compile.js +6 -3
  13. package/src/directive/if.js +0 -79
  14. package/src/directive/if.md +80 -0
  15. package/src/directive/include.js +0 -82
  16. package/src/directive/include.md +86 -0
  17. package/src/directive/repeat.js +0 -1
  18. package/src/filters/order-by.js +8 -8
  19. package/src/loader.js +0 -1
  20. package/src/router/common/trace.js +1 -1
  21. package/src/router/directives/stateDirectives.js +16 -14
  22. package/src/router/directives/viewDirective.js +5 -13
  23. package/src/router/hooks/resolve.js +3 -4
  24. package/src/router/hooks/views.js +3 -2
  25. package/src/router/state/stateService.js +1 -2
  26. package/src/router/stateProvider.js +8 -0
  27. package/src/router/templateFactory.js +13 -7
  28. package/src/router/transition/interface.js +14 -14
  29. package/src/router/transition/rejectFactory.js +29 -20
  30. package/src/router/transition/transition.js +5 -1
  31. package/src/router/transition/transitionHook.js +5 -5
  32. package/src/router/url/urlMatcher.js +1 -2
  33. package/src/router/url/urlRule.js +10 -2
  34. package/src/router/url/urlRules.js +1 -1
  35. package/src/services/browser.js +3 -18
  36. package/src/shared/common.js +0 -1
  37. package/test/module-test.html +44 -12
  38. package/test/router/ng-state-builder.spec.js +81 -0
  39. package/test/router/services.spec.js +70 -0
  40. package/test/router/state-directives.spec.js +1182 -0
  41. package/test/router/template-factory.spec.js +146 -0
  42. package/test/router/url-matcher-factory.spec.js +1313 -0
  43. package/test/router/view-directive.spec.js +2013 -0
  44. package/test/router/view-hook.spec.js +217 -0
  45. package/test/router/view-scroll.spec.js +77 -0
  46. package/test/router/view.spec.js +117 -0
  47. package/types/angular.d.ts +132 -124
  48. package/types/index.d.ts +2350 -2187
  49. package/types/jqlite.d.ts +463 -418
  50. package/types/router/core/common/common.d.ts +70 -24
  51. package/types/router/core/common/coreservices.d.ts +30 -32
  52. package/types/router/core/common/glob.d.ts +9 -9
  53. package/types/router/core/common/hof.d.ts +12 -4
  54. package/types/router/core/common/index.d.ts +8 -8
  55. package/types/router/core/common/predicates.d.ts +1 -1
  56. package/types/router/core/common/queue.d.ts +13 -13
  57. package/types/router/core/common/safeConsole.d.ts +3 -3
  58. package/types/router/core/common/strings.d.ts +4 -2
  59. package/types/router/core/common/trace.d.ts +94 -82
  60. package/types/router/core/globals.d.ts +37 -37
  61. package/types/router/core/hooks/coreResolvables.d.ts +5 -3
  62. package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
  63. package/types/router/core/hooks/invalidTransition.d.ts +4 -2
  64. package/types/router/core/hooks/lazyLoad.d.ts +10 -5
  65. package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
  66. package/types/router/core/hooks/redirectTo.d.ts +4 -2
  67. package/types/router/core/hooks/resolve.d.ts +10 -4
  68. package/types/router/core/hooks/updateGlobals.d.ts +4 -2
  69. package/types/router/core/hooks/url.d.ts +4 -2
  70. package/types/router/core/hooks/views.d.ts +7 -3
  71. package/types/router/core/index.d.ts +11 -12
  72. package/types/router/core/interface.d.ts +83 -81
  73. package/types/router/core/params/index.d.ts +5 -5
  74. package/types/router/core/params/interface.d.ts +439 -439
  75. package/types/router/core/params/param.d.ts +72 -60
  76. package/types/router/core/params/paramType.d.ts +40 -40
  77. package/types/router/core/params/paramTypes.d.ts +169 -165
  78. package/types/router/core/params/stateParams.d.ts +13 -13
  79. package/types/router/core/path/index.d.ts +2 -2
  80. package/types/router/core/path/pathNode.d.ts +49 -49
  81. package/types/router/core/path/pathUtils.d.ts +100 -74
  82. package/types/router/core/resolve/index.d.ts +3 -3
  83. package/types/router/core/resolve/interface.d.ts +137 -137
  84. package/types/router/core/resolve/resolvable.d.ts +60 -54
  85. package/types/router/core/resolve/resolveContext.d.ts +84 -79
  86. package/types/router/core/router.d.ts +95 -86
  87. package/types/router/core/state/index.d.ts +8 -8
  88. package/types/router/core/state/interface.d.ts +667 -643
  89. package/types/router/core/state/stateBuilder.d.ts +41 -38
  90. package/types/router/core/state/stateMatcher.d.ts +11 -9
  91. package/types/router/core/state/stateObject.d.ts +154 -139
  92. package/types/router/core/state/stateQueueManager.d.ts +26 -21
  93. package/types/router/core/state/stateRegistry.d.ts +124 -121
  94. package/types/router/core/state/stateService.d.ts +380 -343
  95. package/types/router/core/state/targetState.d.ts +74 -69
  96. package/types/router/core/transition/hookBuilder.d.ts +34 -30
  97. package/types/router/core/transition/hookRegistry.d.ts +96 -74
  98. package/types/router/core/transition/index.d.ts +8 -8
  99. package/types/router/core/transition/interface.d.ts +652 -609
  100. package/types/router/core/transition/rejectFactory.d.ts +97 -97
  101. package/types/router/core/transition/transition.d.ts +565 -517
  102. package/types/router/core/transition/transitionEventType.d.ts +20 -11
  103. package/types/router/core/transition/transitionHook.d.ts +90 -82
  104. package/types/router/core/transition/transitionService.d.ts +228 -161
  105. package/types/router/core/url/index.d.ts +8 -8
  106. package/types/router/core/url/interface.d.ts +100 -87
  107. package/types/router/core/url/urlConfig.d.ts +130 -126
  108. package/types/router/core/url/urlMatcher.d.ts +132 -127
  109. package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
  110. package/types/router/core/url/urlRouter.d.ts +91 -75
  111. package/types/router/core/url/urlRule.d.ts +123 -100
  112. package/types/router/core/url/urlRules.d.ts +240 -232
  113. package/types/router/core/url/urlService.d.ts +201 -201
  114. package/types/router/core/view/index.d.ts +2 -2
  115. package/types/router/core/view/interface.d.ts +26 -26
  116. package/types/router/core/view/view.d.ts +152 -143
  117. package/types/router/directives/viewDirective.d.ts +12 -11
  118. package/types/router/index.d.ts +11 -12
  119. package/types/router/interface.d.ts +361 -351
  120. package/types/router/legacy/resolveService.d.ts +44 -40
  121. package/types/router/legacy/stateEvents.d.ts +1 -1
  122. package/types/router/locationServices.d.ts +45 -37
  123. package/types/router/services.d.ts +9 -9
  124. package/types/router/stateFilters.d.ts +3 -3
  125. package/types/router/stateProvider.d.ts +240 -235
  126. package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
  127. package/types/router/statebuilders/views.d.ts +35 -22
  128. package/types/router/templateFactory.d.ts +99 -79
  129. package/types/router/viewScroll.d.ts +7 -7
  130. package/src/directive/a.js +0 -37
  131. package/types/router/angular.d.ts +0 -1
  132. package/types/router/core/vanilla.d.ts +0 -1
  133. package/types/router/directives/stateDirectives.d.ts +0 -3
  134. package/types/router/injectables.d.ts +0 -1
@@ -1,350 +1,387 @@
1
- import { HookResult, TransitionOptions } from '../transition/interface';
2
- import { Transition } from '../transition/transition';
3
- import { HrefOptions, LazyLoadResult, StateDeclaration, StateOrName, TransitionPromise } from './interface';
4
- import { StateObject } from './stateObject';
5
- import { TargetState } from './targetState';
6
- import { RawParams } from '../params/interface';
7
- import { UIRouter } from '../router';
8
- import { UIInjector } from '../interface';
9
- import { StateParams } from '../params/stateParams';
10
- export declare type OnInvalidCallback = (toState?: TargetState, fromState?: TargetState, injector?: UIInjector) => HookResult;
1
+ import { HookResult, TransitionOptions } from "../transition/interface";
2
+ import { Transition } from "../transition/transition";
3
+ import {
4
+ HrefOptions,
5
+ LazyLoadResult,
6
+ StateDeclaration,
7
+ StateOrName,
8
+ TransitionPromise,
9
+ } from "./interface";
10
+ import { StateObject } from "./stateObject";
11
+ import { TargetState } from "./targetState";
12
+ import { RawParams } from "../params/interface";
13
+ import { UIRouter } from "../router";
14
+ import { UIInjector } from "../interface";
15
+ import { StateParams } from "../params/stateParams";
16
+ export declare type OnInvalidCallback = (
17
+ toState?: TargetState,
18
+ fromState?: TargetState,
19
+ injector?: UIInjector,
20
+ ) => HookResult;
11
21
  /**
12
22
  * Provides services related to ui-router states.
13
23
  *
14
24
  * This API is located at `router.stateService` ([[UIRouter.stateService]])
15
25
  */
16
26
  export declare class StateService {
17
- private router;
18
- /** @internal */
19
- invalidCallbacks: OnInvalidCallback[];
20
- /**
21
- * The [[Transition]] currently in progress (or null)
22
- *
23
- * @deprecated This is a passthrough through to [[UIRouterGlobals.transition]]
24
- */
25
- transition: Transition;
26
- /**
27
- * The latest successful state parameters
28
- *
29
- * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
30
- */
31
- params: StateParams;
32
- /**
33
- * The current [[StateDeclaration]]
34
- *
35
- * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
36
- */
37
- current: StateDeclaration;
38
- /**
39
- * The current [[StateObject]] (an internal API)
40
- *
41
- * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
42
- */
43
- $current: StateObject;
44
- /** @internal */
45
- constructor(/** @internal */ router: UIRouter);
46
- /** @internal */
47
- dispose(): void;
48
- /**
49
- * Handler for when [[transitionTo]] is called with an invalid state.
50
- *
51
- * Invokes the [[onInvalid]] callbacks, in natural order.
52
- * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
53
- * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
54
- *
55
- * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
56
- *
57
- * @internal
58
- */
59
- private _handleInvalidTargetState;
60
- /**
61
- * Registers an Invalid State handler
62
- *
63
- * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
64
- * has been called with an invalid state reference parameter
65
- *
66
- * Example:
67
- * ```js
68
- * stateService.onInvalid(function(to, from, injector) {
69
- * if (to.name() === 'foo') {
70
- * let lazyLoader = injector.get('LazyLoadService');
71
- * return lazyLoader.load('foo')
72
- * .then(() => stateService.target('foo'));
73
- * }
74
- * });
75
- * ```
76
- *
77
- * @param {function} callback invoked when the toState is invalid
78
- * This function receives the (invalid) toState, the fromState, and an injector.
79
- * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
80
- * If one is returned, it is treated as a redirect.
81
- *
82
- * @returns a function which deregisters the callback
83
- */
84
- onInvalid(callback: OnInvalidCallback): Function;
85
- /**
86
- * Reloads the current state
87
- *
88
- * A method that force reloads the current state, or a partial state hierarchy.
89
- * All resolves are re-resolved, and components reinstantiated.
90
- *
91
- * #### Example:
92
- * ```js
93
- * let app angular.module('app', ['ui.router']);
94
- *
95
- * app.controller('ctrl', function ($scope, $state) {
96
- * $scope.reload = function(){
97
- * $state.reload();
98
- * }
99
- * });
100
- * ```
101
- *
102
- * Note: `reload()` is just an alias for:
103
- *
104
- * ```js
105
- * $state.transitionTo($state.current, $state.params, {
106
- * reload: true, inherit: false
107
- * });
108
- * ```
109
- *
110
- * @param reloadState A state name or a state object.
111
- * If present, this state and all its children will be reloaded, but ancestors will not reload.
112
- *
113
- * #### Example:
114
- * ```js
115
- * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
116
- * //and current state is 'contacts.detail.item'
117
- * let app angular.module('app', ['ui.router']);
118
- *
119
- * app.controller('ctrl', function ($scope, $state) {
120
- * $scope.reload = function(){
121
- * //will reload 'contact.detail' and nested 'contact.detail.item' states
122
- * $state.reload('contact.detail');
123
- * }
124
- * });
125
- * ```
126
- *
127
- * @returns A promise representing the state of the new transition. See [[StateService.go]]
128
- */
129
- reload(reloadState?: StateOrName): Promise<StateObject>;
130
- /**
131
- * Transition to a different state and/or parameters
132
- *
133
- * Convenience method for transitioning to a new state.
134
- *
135
- * `$state.go` calls `$state.transitionTo` internally but automatically sets options to
136
- * `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
137
- * This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
138
- * It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
139
- * inherit from the current parameter values (because of `inherit: true`).
140
- *
141
- * #### Example:
142
- * ```js
143
- * let app = angular.module('app', ['ui.router']);
144
- *
145
- * app.controller('ctrl', function ($scope, $state) {
146
- * $scope.changeState = function () {
147
- * $state.go('contact.detail');
148
- * };
149
- * });
150
- * ```
151
- *
152
- * @param to Absolute state name, state object, or relative state path (relative to current state).
153
- *
154
- * Some examples:
155
- *
156
- * - `$state.go('contact.detail')` - will go to the `contact.detail` state
157
- * - `$state.go('^')` - will go to the parent state
158
- * - `$state.go('^.sibling')` - if current state is `home.child`, will go to the `home.sibling` state
159
- * - `$state.go('.child.grandchild')` - if current state is home, will go to the `home.child.grandchild` state
160
- *
161
- * @param params A map of the parameters that will be sent to the state, will populate $stateParams.
162
- *
163
- * Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
164
- * This allows, for example, going to a sibling state that shares parameters defined by a parent state.
165
- *
166
- * @param options Transition options
167
- *
168
- * @returns {promise} A promise representing the state of the new transition.
169
- */
170
- go(to: StateOrName, params?: RawParams, options?: TransitionOptions): TransitionPromise;
171
- /**
172
- * Creates a [[TargetState]]
173
- *
174
- * This is a factory method for creating a TargetState
175
- *
176
- * This may be returned from a Transition Hook to redirect a transition, for example.
177
- */
178
- target(identifier: StateOrName, params?: RawParams, options?: TransitionOptions): TargetState;
179
- /** @internal */
180
- private getCurrentPath;
181
- /**
182
- * Low-level method for transitioning to a new state.
183
- *
184
- * The [[go]] method (which uses `transitionTo` internally) is recommended in most situations.
185
- *
186
- * #### Example:
187
- * ```js
188
- * let app = angular.module('app', ['ui.router']);
189
- *
190
- * app.controller('ctrl', function ($scope, $state) {
191
- * $scope.changeState = function () {
192
- * $state.transitionTo('contact.detail');
193
- * };
194
- * });
195
- * ```
196
- *
197
- * @param to State name or state object.
198
- * @param toParams A map of the parameters that will be sent to the state,
199
- * will populate $stateParams.
200
- * @param options Transition options
201
- *
202
- * @returns A promise representing the state of the new transition. See [[go]]
203
- */
204
- transitionTo(to: StateOrName, toParams?: RawParams, options?: TransitionOptions): TransitionPromise;
205
- /**
206
- * Checks if the current state *is* the provided state
207
- *
208
- * Similar to [[includes]] but only checks for the full state name.
209
- * If params is supplied then it will be tested for strict equality against the current
210
- * active params object, so all params must match with none missing and no extras.
211
- *
212
- * #### Example:
213
- * ```js
214
- * $state.$current.name = 'contacts.details.item';
215
- *
216
- * // absolute name
217
- * $state.is('contact.details.item'); // returns true
218
- * $state.is(contactDetailItemStateObject); // returns true
219
- * ```
220
- *
221
- * // relative name (. and ^), typically from a template
222
- * // E.g. from the 'contacts.details' template
223
- * ```html
224
- * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
225
- * ```
226
- *
227
- * @param stateOrName The state name (absolute or relative) or state object you'd like to check.
228
- * @param params A param object, e.g. `{sectionId: section.id}`, that you'd like
229
- * to test against the current active state.
230
- * @param options An options object. The options are:
231
- * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
232
- * test relative to `options.relative` state (or name).
233
- *
234
- * @returns Returns true if it is the state.
235
- */
236
- is(stateOrName: StateOrName, params?: RawParams, options?: {
237
- relative?: StateOrName;
238
- }): boolean;
239
- /**
240
- * Checks if the current state *includes* the provided state
241
- *
242
- * A method to determine if the current active state is equal to or is the child of the
243
- * state stateName. If any params are passed then they will be tested for a match as well.
244
- * Not all the parameters need to be passed, just the ones you'd like to test for equality.
245
- *
246
- * #### Example when `$state.$current.name === 'contacts.details.item'`
247
- * ```js
248
- * // Using partial names
249
- * $state.includes("contacts"); // returns true
250
- * $state.includes("contacts.details"); // returns true
251
- * $state.includes("contacts.details.item"); // returns true
252
- * $state.includes("contacts.list"); // returns false
253
- * $state.includes("about"); // returns false
254
- * ```
255
- *
256
- * #### Glob Examples when `* $state.$current.name === 'contacts.details.item.url'`:
257
- * ```js
258
- * $state.includes("*.details.*.*"); // returns true
259
- * $state.includes("*.details.**"); // returns true
260
- * $state.includes("**.item.**"); // returns true
261
- * $state.includes("*.details.item.url"); // returns true
262
- * $state.includes("*.details.*.url"); // returns true
263
- * $state.includes("*.details.*"); // returns false
264
- * $state.includes("item.**"); // returns false
265
- * ```
266
- *
267
- * @param stateOrName A partial name, relative name, glob pattern,
268
- * or state object to be searched for within the current state name.
269
- * @param params A param object, e.g. `{sectionId: section.id}`,
270
- * that you'd like to test against the current active state.
271
- * @param options An options object. The options are:
272
- * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
273
- * test relative to `options.relative` state (or name).
274
- *
275
- * @returns {boolean} Returns true if it does include the state
276
- */
277
- includes(stateOrName: StateOrName, params?: RawParams, options?: TransitionOptions): boolean;
278
- /**
279
- * Generates a URL for a state and parameters
280
- *
281
- * Returns the url for the given state populated with the given params.
282
- *
283
- * #### Example:
284
- * ```js
285
- * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
286
- * ```
287
- *
288
- * @param stateOrName The state name or state object you'd like to generate a url from.
289
- * @param params An object of parameter values to fill the state's required parameters.
290
- * @param options Options object. The options are:
291
- *
292
- * @returns {string} compiled state url
293
- */
294
- href(stateOrName: StateOrName, params?: RawParams, options?: HrefOptions): string;
295
- /** @internal */
296
- private _defaultErrorHandler;
297
- /**
298
- * Sets or gets the default [[transitionTo]] error handler.
299
- *
300
- * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
301
- * This includes errors caused by resolves and transition hooks.
302
- *
303
- * Note:
304
- * This handler does not receive certain Transition rejections.
305
- * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
306
- *
307
- * The built-in default error handler logs the error to the console.
308
- *
309
- * You can provide your own custom handler.
310
- *
311
- * #### Example:
312
- * ```js
313
- * stateService.defaultErrorHandler(function() {
314
- * // Do not log transitionTo errors
315
- * });
316
- * ```
317
- *
318
- * @param handler a global error handler function
319
- * @returns the current global error handler
320
- */
321
- defaultErrorHandler(handler?: (error: any) => void): (error: any) => void;
322
- /**
323
- * Gets a registered [[StateDeclaration]] object
324
- *
325
- * Returns the state declaration object for any specific state, or for all registered states.
326
- *
327
- * @param stateOrName (absolute or relative) If provided, will only get the declaration object for the requested state.
328
- * If not provided, returns an array of ALL states.
329
- * @param base When `stateOrName` is a relative state reference (such as `.bar.baz`), the state will be retrieved relative to this state.
330
- *
331
- * @returns a [[StateDeclaration]] object (or array of all registered [[StateDeclaration]] objects.)
332
- * @deprecated use [[StateRegistry.get]]
333
- */
334
- get(stateOrName: StateOrName, base: StateOrName): StateDeclaration;
335
- get(stateOrName: StateOrName): StateDeclaration;
336
- get(): StateDeclaration[];
337
- /**
338
- * Lazy loads a state
339
- *
340
- * Explicitly runs a state's [[StateDeclaration.lazyLoad]] function.
341
- *
342
- * @param stateOrName the state that should be lazy loaded
343
- * @param transition the optional Transition context to use (if the lazyLoad function requires an injector, etc)
344
- * Note: If no transition is provided, a noop transition is created using the from the current state to the current state.
345
- * This noop transition is not actually run.
346
- *
347
- * @returns a promise to lazy load
348
- */
349
- lazyLoad(stateOrName: StateOrName, transition?: Transition): Promise<LazyLoadResult>;
27
+ private router;
28
+ /** @internal */
29
+ invalidCallbacks: OnInvalidCallback[];
30
+ /**
31
+ * The [[Transition]] currently in progress (or null)
32
+ *
33
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.transition]]
34
+ */
35
+ transition: Transition;
36
+ /**
37
+ * The latest successful state parameters
38
+ *
39
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
40
+ */
41
+ params: StateParams;
42
+ /**
43
+ * The current [[StateDeclaration]]
44
+ *
45
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
46
+ */
47
+ current: StateDeclaration;
48
+ /**
49
+ * The current [[StateObject]] (an internal API)
50
+ *
51
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
52
+ */
53
+ $current: StateObject;
54
+ /** @internal */
55
+ constructor(/** @internal */ router: UIRouter);
56
+ /** @internal */
57
+ dispose(): void;
58
+ /**
59
+ * Handler for when [[transitionTo]] is called with an invalid state.
60
+ *
61
+ * Invokes the [[onInvalid]] callbacks, in natural order.
62
+ * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
63
+ * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
64
+ *
65
+ * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
66
+ *
67
+ * @internal
68
+ */
69
+ private _handleInvalidTargetState;
70
+ /**
71
+ * Registers an Invalid State handler
72
+ *
73
+ * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
74
+ * has been called with an invalid state reference parameter
75
+ *
76
+ * Example:
77
+ * ```js
78
+ * stateService.onInvalid(function(to, from, injector) {
79
+ * if (to.name() === 'foo') {
80
+ * let lazyLoader = injector.get('LazyLoadService');
81
+ * return lazyLoader.load('foo')
82
+ * .then(() => stateService.target('foo'));
83
+ * }
84
+ * });
85
+ * ```
86
+ *
87
+ * @param {function} callback invoked when the toState is invalid
88
+ * This function receives the (invalid) toState, the fromState, and an injector.
89
+ * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
90
+ * If one is returned, it is treated as a redirect.
91
+ *
92
+ * @returns a function which deregisters the callback
93
+ */
94
+ onInvalid(callback: OnInvalidCallback): Function;
95
+ /**
96
+ * Reloads the current state
97
+ *
98
+ * A method that force reloads the current state, or a partial state hierarchy.
99
+ * All resolves are re-resolved, and components reinstantiated.
100
+ *
101
+ * #### Example:
102
+ * ```js
103
+ * let app angular.module('app', ['ui.router']);
104
+ *
105
+ * app.controller('ctrl', function ($scope, $state) {
106
+ * $scope.reload = function(){
107
+ * $state.reload();
108
+ * }
109
+ * });
110
+ * ```
111
+ *
112
+ * Note: `reload()` is just an alias for:
113
+ *
114
+ * ```js
115
+ * $state.transitionTo($state.current, $state.params, {
116
+ * reload: true, inherit: false
117
+ * });
118
+ * ```
119
+ *
120
+ * @param reloadState A state name or a state object.
121
+ * If present, this state and all its children will be reloaded, but ancestors will not reload.
122
+ *
123
+ * #### Example:
124
+ * ```js
125
+ * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
126
+ * //and current state is 'contacts.detail.item'
127
+ * let app angular.module('app', ['ui.router']);
128
+ *
129
+ * app.controller('ctrl', function ($scope, $state) {
130
+ * $scope.reload = function(){
131
+ * //will reload 'contact.detail' and nested 'contact.detail.item' states
132
+ * $state.reload('contact.detail');
133
+ * }
134
+ * });
135
+ * ```
136
+ *
137
+ * @returns A promise representing the state of the new transition. See [[StateService.go]]
138
+ */
139
+ reload(reloadState?: StateOrName): Promise<StateObject>;
140
+ /**
141
+ * Transition to a different state and/or parameters
142
+ *
143
+ * Convenience method for transitioning to a new state.
144
+ *
145
+ * `$state.go` calls `$state.transitionTo` internally but automatically sets options to
146
+ * `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
147
+ * This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
148
+ * It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
149
+ * inherit from the current parameter values (because of `inherit: true`).
150
+ *
151
+ * #### Example:
152
+ * ```js
153
+ * let app = angular.module('app', ['ui.router']);
154
+ *
155
+ * app.controller('ctrl', function ($scope, $state) {
156
+ * $scope.changeState = function () {
157
+ * $state.go('contact.detail');
158
+ * };
159
+ * });
160
+ * ```
161
+ *
162
+ * @param to Absolute state name, state object, or relative state path (relative to current state).
163
+ *
164
+ * Some examples:
165
+ *
166
+ * - `$state.go('contact.detail')` - will go to the `contact.detail` state
167
+ * - `$state.go('^')` - will go to the parent state
168
+ * - `$state.go('^.sibling')` - if current state is `home.child`, will go to the `home.sibling` state
169
+ * - `$state.go('.child.grandchild')` - if current state is home, will go to the `home.child.grandchild` state
170
+ *
171
+ * @param params A map of the parameters that will be sent to the state, will populate $stateParams.
172
+ *
173
+ * Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
174
+ * This allows, for example, going to a sibling state that shares parameters defined by a parent state.
175
+ *
176
+ * @param options Transition options
177
+ *
178
+ * @returns {promise} A promise representing the state of the new transition.
179
+ */
180
+ go(
181
+ to: StateOrName,
182
+ params?: RawParams,
183
+ options?: TransitionOptions,
184
+ ): TransitionPromise;
185
+ /**
186
+ * Creates a [[TargetState]]
187
+ *
188
+ * This is a factory method for creating a TargetState
189
+ *
190
+ * This may be returned from a Transition Hook to redirect a transition, for example.
191
+ */
192
+ target(
193
+ identifier: StateOrName,
194
+ params?: RawParams,
195
+ options?: TransitionOptions,
196
+ ): TargetState;
197
+ /** @internal */
198
+ private getCurrentPath;
199
+ /**
200
+ * Low-level method for transitioning to a new state.
201
+ *
202
+ * The [[go]] method (which uses `transitionTo` internally) is recommended in most situations.
203
+ *
204
+ * #### Example:
205
+ * ```js
206
+ * let app = angular.module('app', ['ui.router']);
207
+ *
208
+ * app.controller('ctrl', function ($scope, $state) {
209
+ * $scope.changeState = function () {
210
+ * $state.transitionTo('contact.detail');
211
+ * };
212
+ * });
213
+ * ```
214
+ *
215
+ * @param to State name or state object.
216
+ * @param toParams A map of the parameters that will be sent to the state,
217
+ * will populate $stateParams.
218
+ * @param options Transition options
219
+ *
220
+ * @returns A promise representing the state of the new transition. See [[go]]
221
+ */
222
+ transitionTo(
223
+ to: StateOrName,
224
+ toParams?: RawParams,
225
+ options?: TransitionOptions,
226
+ ): TransitionPromise;
227
+ /**
228
+ * Checks if the current state *is* the provided state
229
+ *
230
+ * Similar to [[includes]] but only checks for the full state name.
231
+ * If params is supplied then it will be tested for strict equality against the current
232
+ * active params object, so all params must match with none missing and no extras.
233
+ *
234
+ * #### Example:
235
+ * ```js
236
+ * $state.$current.name = 'contacts.details.item';
237
+ *
238
+ * // absolute name
239
+ * $state.is('contact.details.item'); // returns true
240
+ * $state.is(contactDetailItemStateObject); // returns true
241
+ * ```
242
+ *
243
+ * // relative name (. and ^), typically from a template
244
+ * // E.g. from the 'contacts.details' template
245
+ * ```html
246
+ * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
247
+ * ```
248
+ *
249
+ * @param stateOrName The state name (absolute or relative) or state object you'd like to check.
250
+ * @param params A param object, e.g. `{sectionId: section.id}`, that you'd like
251
+ * to test against the current active state.
252
+ * @param options An options object. The options are:
253
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
254
+ * test relative to `options.relative` state (or name).
255
+ *
256
+ * @returns Returns true if it is the state.
257
+ */
258
+ is(
259
+ stateOrName: StateOrName,
260
+ params?: RawParams,
261
+ options?: {
262
+ relative?: StateOrName;
263
+ },
264
+ ): boolean;
265
+ /**
266
+ * Checks if the current state *includes* the provided state
267
+ *
268
+ * A method to determine if the current active state is equal to or is the child of the
269
+ * state stateName. If any params are passed then they will be tested for a match as well.
270
+ * Not all the parameters need to be passed, just the ones you'd like to test for equality.
271
+ *
272
+ * #### Example when `$state.$current.name === 'contacts.details.item'`
273
+ * ```js
274
+ * // Using partial names
275
+ * $state.includes("contacts"); // returns true
276
+ * $state.includes("contacts.details"); // returns true
277
+ * $state.includes("contacts.details.item"); // returns true
278
+ * $state.includes("contacts.list"); // returns false
279
+ * $state.includes("about"); // returns false
280
+ * ```
281
+ *
282
+ * #### Glob Examples when `* $state.$current.name === 'contacts.details.item.url'`:
283
+ * ```js
284
+ * $state.includes("*.details.*.*"); // returns true
285
+ * $state.includes("*.details.**"); // returns true
286
+ * $state.includes("**.item.**"); // returns true
287
+ * $state.includes("*.details.item.url"); // returns true
288
+ * $state.includes("*.details.*.url"); // returns true
289
+ * $state.includes("*.details.*"); // returns false
290
+ * $state.includes("item.**"); // returns false
291
+ * ```
292
+ *
293
+ * @param stateOrName A partial name, relative name, glob pattern,
294
+ * or state object to be searched for within the current state name.
295
+ * @param params A param object, e.g. `{sectionId: section.id}`,
296
+ * that you'd like to test against the current active state.
297
+ * @param options An options object. The options are:
298
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
299
+ * test relative to `options.relative` state (or name).
300
+ *
301
+ * @returns {boolean} Returns true if it does include the state
302
+ */
303
+ includes(
304
+ stateOrName: StateOrName,
305
+ params?: RawParams,
306
+ options?: TransitionOptions,
307
+ ): boolean;
308
+ /**
309
+ * Generates a URL for a state and parameters
310
+ *
311
+ * Returns the url for the given state populated with the given params.
312
+ *
313
+ * #### Example:
314
+ * ```js
315
+ * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
316
+ * ```
317
+ *
318
+ * @param stateOrName The state name or state object you'd like to generate a url from.
319
+ * @param params An object of parameter values to fill the state's required parameters.
320
+ * @param options Options object. The options are:
321
+ *
322
+ * @returns {string} compiled state url
323
+ */
324
+ href(
325
+ stateOrName: StateOrName,
326
+ params?: RawParams,
327
+ options?: HrefOptions,
328
+ ): string;
329
+ /** @internal */
330
+ private _defaultErrorHandler;
331
+ /**
332
+ * Sets or gets the default [[transitionTo]] error handler.
333
+ *
334
+ * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
335
+ * This includes errors caused by resolves and transition hooks.
336
+ *
337
+ * Note:
338
+ * This handler does not receive certain Transition rejections.
339
+ * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
340
+ *
341
+ * The built-in default error handler logs the error to the console.
342
+ *
343
+ * You can provide your own custom handler.
344
+ *
345
+ * #### Example:
346
+ * ```js
347
+ * stateService.defaultErrorHandler(function() {
348
+ * // Do not log transitionTo errors
349
+ * });
350
+ * ```
351
+ *
352
+ * @param handler a global error handler function
353
+ * @returns the current global error handler
354
+ */
355
+ defaultErrorHandler(handler?: (error: any) => void): (error: any) => void;
356
+ /**
357
+ * Gets a registered [[StateDeclaration]] object
358
+ *
359
+ * Returns the state declaration object for any specific state, or for all registered states.
360
+ *
361
+ * @param stateOrName (absolute or relative) If provided, will only get the declaration object for the requested state.
362
+ * If not provided, returns an array of ALL states.
363
+ * @param base When `stateOrName` is a relative state reference (such as `.bar.baz`), the state will be retrieved relative to this state.
364
+ *
365
+ * @returns a [[StateDeclaration]] object (or array of all registered [[StateDeclaration]] objects.)
366
+ * @deprecated use [[StateRegistry.get]]
367
+ */
368
+ get(stateOrName: StateOrName, base: StateOrName): StateDeclaration;
369
+ get(stateOrName: StateOrName): StateDeclaration;
370
+ get(): StateDeclaration[];
371
+ /**
372
+ * Lazy loads a state
373
+ *
374
+ * Explicitly runs a state's [[StateDeclaration.lazyLoad]] function.
375
+ *
376
+ * @param stateOrName the state that should be lazy loaded
377
+ * @param transition the optional Transition context to use (if the lazyLoad function requires an injector, etc)
378
+ * Note: If no transition is provided, a noop transition is created using the from the current state to the current state.
379
+ * This noop transition is not actually run.
380
+ *
381
+ * @returns a promise to lazy load
382
+ */
383
+ lazyLoad(
384
+ stateOrName: StateOrName,
385
+ transition?: Transition,
386
+ ): Promise<LazyLoadResult>;
350
387
  }