@angular-wave/angular.ts 0.0.20 → 0.0.22

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 (128) hide show
  1. package/Makefile +1 -1
  2. package/README.md +3 -3
  3. package/TODO.md +14 -0
  4. package/dist/angular-ts.esm.js +1 -1
  5. package/dist/angular-ts.umd.js +1 -1
  6. package/index.html +2 -1
  7. package/package.json +1 -1
  8. package/src/animations/animate-css-driver.js +2 -2
  9. package/src/animations/animate-css.js +15 -6
  10. package/src/animations/animate-js.js +1 -1
  11. package/src/animations/animate-queue.js +1 -1
  12. package/src/animations/shared.js +0 -14
  13. package/src/core/compile.js +6 -3
  14. package/src/core/q.js +9 -9
  15. package/src/core/sanitize-uri.js +1 -1
  16. package/src/core/sce.js +1 -1
  17. package/src/directive/if.js +0 -79
  18. package/src/directive/if.md +80 -0
  19. package/src/directive/include.js +0 -82
  20. package/src/directive/include.md +86 -0
  21. package/src/directive/repeat.js +0 -1
  22. package/src/loader.js +0 -1
  23. package/src/public.js +0 -2
  24. package/src/router/common/trace.js +1 -1
  25. package/src/router/directives/stateDirectives.js +16 -14
  26. package/src/router/directives/viewDirective.js +2 -2
  27. package/src/router/hooks/resolve.js +3 -4
  28. package/src/router/hooks/views.js +3 -2
  29. package/src/router/state/stateService.js +1 -2
  30. package/src/router/transition/interface.js +14 -14
  31. package/src/router/transition/rejectFactory.js +29 -20
  32. package/src/router/transition/transitionHook.js +5 -5
  33. package/src/router/url/urlMatcher.js +1 -2
  34. package/src/router/url/urlRule.js +1 -1
  35. package/src/router/url/urlRules.js +1 -1
  36. package/src/shared/common.js +0 -1
  37. package/test/module-test.html +44 -12
  38. package/test/router/services.spec.js +71 -0
  39. package/test/router/state-directives.spec.js +1208 -0
  40. package/types/angular.d.ts +132 -124
  41. package/types/index.d.ts +2350 -2187
  42. package/types/jqlite.d.ts +463 -418
  43. package/types/router/core/common/common.d.ts +70 -24
  44. package/types/router/core/common/coreservices.d.ts +30 -32
  45. package/types/router/core/common/glob.d.ts +9 -9
  46. package/types/router/core/common/hof.d.ts +12 -4
  47. package/types/router/core/common/index.d.ts +8 -8
  48. package/types/router/core/common/predicates.d.ts +1 -1
  49. package/types/router/core/common/queue.d.ts +13 -13
  50. package/types/router/core/common/safeConsole.d.ts +3 -3
  51. package/types/router/core/common/strings.d.ts +4 -2
  52. package/types/router/core/common/trace.d.ts +94 -82
  53. package/types/router/core/globals.d.ts +37 -37
  54. package/types/router/core/hooks/coreResolvables.d.ts +5 -3
  55. package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
  56. package/types/router/core/hooks/invalidTransition.d.ts +4 -2
  57. package/types/router/core/hooks/lazyLoad.d.ts +10 -5
  58. package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
  59. package/types/router/core/hooks/redirectTo.d.ts +4 -2
  60. package/types/router/core/hooks/resolve.d.ts +10 -4
  61. package/types/router/core/hooks/updateGlobals.d.ts +4 -2
  62. package/types/router/core/hooks/url.d.ts +4 -2
  63. package/types/router/core/hooks/views.d.ts +7 -3
  64. package/types/router/core/index.d.ts +11 -12
  65. package/types/router/core/interface.d.ts +83 -81
  66. package/types/router/core/params/index.d.ts +5 -5
  67. package/types/router/core/params/interface.d.ts +439 -439
  68. package/types/router/core/params/param.d.ts +72 -60
  69. package/types/router/core/params/paramType.d.ts +40 -40
  70. package/types/router/core/params/paramTypes.d.ts +169 -165
  71. package/types/router/core/params/stateParams.d.ts +13 -13
  72. package/types/router/core/path/index.d.ts +2 -2
  73. package/types/router/core/path/pathNode.d.ts +49 -49
  74. package/types/router/core/path/pathUtils.d.ts +100 -74
  75. package/types/router/core/resolve/index.d.ts +3 -3
  76. package/types/router/core/resolve/interface.d.ts +137 -137
  77. package/types/router/core/resolve/resolvable.d.ts +60 -54
  78. package/types/router/core/resolve/resolveContext.d.ts +84 -79
  79. package/types/router/core/router.d.ts +95 -86
  80. package/types/router/core/state/index.d.ts +8 -8
  81. package/types/router/core/state/interface.d.ts +667 -643
  82. package/types/router/core/state/stateBuilder.d.ts +41 -38
  83. package/types/router/core/state/stateMatcher.d.ts +11 -9
  84. package/types/router/core/state/stateObject.d.ts +154 -139
  85. package/types/router/core/state/stateQueueManager.d.ts +26 -21
  86. package/types/router/core/state/stateRegistry.d.ts +124 -121
  87. package/types/router/core/state/stateService.d.ts +380 -343
  88. package/types/router/core/state/targetState.d.ts +74 -69
  89. package/types/router/core/transition/hookBuilder.d.ts +34 -30
  90. package/types/router/core/transition/hookRegistry.d.ts +96 -74
  91. package/types/router/core/transition/index.d.ts +8 -8
  92. package/types/router/core/transition/interface.d.ts +652 -609
  93. package/types/router/core/transition/rejectFactory.d.ts +97 -97
  94. package/types/router/core/transition/transition.d.ts +565 -517
  95. package/types/router/core/transition/transitionEventType.d.ts +20 -11
  96. package/types/router/core/transition/transitionHook.d.ts +90 -82
  97. package/types/router/core/transition/transitionService.d.ts +228 -161
  98. package/types/router/core/url/index.d.ts +8 -8
  99. package/types/router/core/url/interface.d.ts +100 -87
  100. package/types/router/core/url/urlConfig.d.ts +130 -126
  101. package/types/router/core/url/urlMatcher.d.ts +132 -127
  102. package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
  103. package/types/router/core/url/urlRouter.d.ts +91 -75
  104. package/types/router/core/url/urlRule.d.ts +123 -100
  105. package/types/router/core/url/urlRules.d.ts +240 -232
  106. package/types/router/core/url/urlService.d.ts +201 -201
  107. package/types/router/core/view/index.d.ts +2 -2
  108. package/types/router/core/view/interface.d.ts +26 -26
  109. package/types/router/core/view/view.d.ts +152 -143
  110. package/types/router/directives/viewDirective.d.ts +12 -11
  111. package/types/router/index.d.ts +11 -12
  112. package/types/router/interface.d.ts +361 -351
  113. package/types/router/legacy/resolveService.d.ts +44 -40
  114. package/types/router/legacy/stateEvents.d.ts +1 -1
  115. package/types/router/locationServices.d.ts +45 -37
  116. package/types/router/services.d.ts +9 -9
  117. package/types/router/stateFilters.d.ts +3 -3
  118. package/types/router/stateProvider.d.ts +240 -235
  119. package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
  120. package/types/router/statebuilders/views.d.ts +35 -22
  121. package/types/router/templateFactory.d.ts +99 -79
  122. package/types/router/viewScroll.d.ts +7 -7
  123. package/src/directive/a.js +0 -37
  124. package/test/directive/a.spec.js +0 -192
  125. package/types/router/angular.d.ts +0 -1
  126. package/types/router/core/vanilla.d.ts +0 -1
  127. package/types/router/directives/stateDirectives.d.ts +0 -3
  128. package/types/router/injectables.d.ts +0 -1
@@ -1,5 +1,11 @@
1
1
  /** @publicapi @module ng1 */ /** */
2
- import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult } from './core';
2
+ import {
3
+ StateDeclaration,
4
+ _ViewDeclaration,
5
+ IInjectable,
6
+ Transition,
7
+ HookResult,
8
+ } from "./core";
3
9
  /**
4
10
  * The signature for Angular 1 State Transition Hooks.
5
11
  *
@@ -40,7 +46,7 @@ import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult
40
46
  * @returns an optional [[HookResult]] which may alter the transition
41
47
  */
42
48
  export interface Ng1StateTransitionHook {
43
- (...injectables: any[]): HookResult;
49
+ (...injectables: any[]): HookResult;
44
50
  }
45
51
  /**
46
52
  * @internalapi
@@ -48,10 +54,10 @@ export interface Ng1StateTransitionHook {
48
54
  *
49
55
  * Used to reset [[StateDeclaration]] typings to `any` so the [[Ng1StateDeclaration]] interface can then narrow them */
50
56
  export interface _Ng1StateDeclaration extends StateDeclaration {
51
- onExit?: any;
52
- onRetain?: any;
53
- onEnter?: any;
54
- views?: any;
57
+ onExit?: any;
58
+ onRetain?: any;
59
+ onEnter?: any;
60
+ views?: any;
55
61
  }
56
62
  /**
57
63
  * The StateDeclaration object is used to define a state or nested state.
@@ -118,250 +124,250 @@ export interface _Ng1StateDeclaration extends StateDeclaration {
118
124
  * }
119
125
  * ```
120
126
  */
121
- export interface Ng1StateDeclaration extends _Ng1StateDeclaration, Ng1ViewDeclaration {
122
-
123
- }
127
+ export interface Ng1StateDeclaration
128
+ extends _Ng1StateDeclaration,
129
+ Ng1ViewDeclaration {}
124
130
  export interface Ng1ViewDeclaration extends _ViewDeclaration {
125
- /**
126
- * The name of the component to use for this view.
127
- *
128
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
129
- *
130
- * The name of an [angular 1.5+ `.component()`](https://docs.angularjs.org/guide/component) (or directive with
131
- * bindToController and/or scope declaration) which will be used for this view.
132
- *
133
- * Resolve data can be provided to the component via the component's `bindings` object (for 1.3+ directives, the
134
- * `bindToController` is used; for other directives, the `scope` declaration is used). For each binding declared
135
- * on the component, any resolve with the same name is set on the component's controller instance. The binding
136
- * is provided to the component as a one-time-binding. In general, components should likewise declare their
137
- * input bindings as [one-way ("<")](https://docs.angularjs.org/api/ng/service/$compile#-scope-).
138
- *
139
- * Note: inside a "views:" block, a bare string `"foo"` is shorthand for `{ component: "foo" }`
140
- *
141
- * Note: Mapping from resolve names to component inputs may be specified using [[bindings]].
142
- *
143
- * #### Example:
144
- * ```js
145
- * .state('profile', {
146
- * // Use the <my-profile></my-profile> component for the Unnamed view
147
- * component: 'MyProfile',
148
- * }
149
- *
150
- * .state('messages', {
151
- * // use the <nav-bar></nav-bar> component for the view named 'header'
152
- * // use the <message-list></message-list> component for the view named 'content'
153
- * views: {
154
- * header: { component: 'NavBar' },
155
- * content: { component: 'MessageList' }
156
- * }
157
- * }
158
- *
159
- * .state('contacts', {
160
- * // Inside a "views:" block, a bare string "NavBar" is shorthand for { component: "NavBar" }
161
- * // use the <nav-bar></nav-bar> component for the view named 'header'
162
- * // use the <contact-list></contact-list> component for the view named 'content'
163
- * views: {
164
- * header: 'NavBar',
165
- * content: 'ContactList'
166
- * }
167
- * }
168
- * ```
169
- *
170
- *
171
- * Note: When using `component` to define a view, you may _not_ use any of: `template`, `templateUrl`,
172
- * `templateProvider`, `controller`, `controllerProvider`, `controllerAs`.
173
- *
174
- *
175
- * See also: Todd Motto's angular 1.3 and 1.4 [backport of .component()](https://github.com/toddmotto/angular-component)
176
- */
177
- component?: string;
178
- /**
179
- * An object which maps `resolve`s to [[component]] `bindings`.
180
- *
181
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
182
- *
183
- * When using a [[component]] declaration (`component: 'myComponent'`), each input binding for the component is supplied
184
- * data from a resolve of the same name, by default. You may supply data from a different resolve name by mapping it here.
185
- *
186
- * Each key in this object is the name of one of the component's input bindings.
187
- * Each value is the name of the resolve that should be provided to that binding.
188
- *
189
- * Any component bindings that are omitted from this map get the default behavior of mapping to a resolve of the
190
- * same name.
191
- *
192
- * #### Example:
193
- * ```js
194
- * $stateProvider.state('foo', {
195
- * resolve: {
196
- * foo: function(FooService) { return FooService.get(); },
197
- * bar: function(BarService) { return BarService.get(); }
198
- * },
199
- * component: 'Baz',
200
- * // The component's `baz` binding gets data from the `bar` resolve
201
- * // The component's `foo` binding gets data from the `foo` resolve (default behavior)
202
- * bindings: {
203
- * baz: 'bar'
204
- * }
205
- * });
206
- *
207
- * app.component('Baz', {
208
- * templateUrl: 'baz.html',
209
- * controller: 'BazController',
210
- * bindings: {
211
- * foo: '<', // foo binding
212
- * baz: '<' // baz binding
213
- * }
214
- * });
215
- * ```
216
- *
217
- */
218
- bindings?: {
219
- [key: string]: string;
220
- };
221
- /**
222
- * Dynamic component provider function.
223
- *
224
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
225
- *
226
- * This is an injectable provider function which returns the name of the component to use.
227
- * The provider will invoked during a Transition in which the view's state is entered.
228
- * The provider is called after the resolve data is fetched.
229
- *
230
- * #### Example:
231
- * ```js
232
- * componentProvider: function(MyResolveData, $transition$) {
233
- * if (MyResolveData.foo) {
234
- * return "fooComponent"
235
- * } else if ($transition$.to().name === 'bar') {
236
- * return "barComponent";
237
- * }
238
- * }
239
- * ```
240
- */
241
- componentProvider?: IInjectable;
242
- /**
243
- * The view's controller function or name
244
- *
245
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
246
- *
247
- * The controller function, or the name of a registered controller. The controller function will be used
248
- * to control the contents of the [[directives.uiView]] directive.
249
- *
250
- * If specified as a string, controllerAs can be declared here, i.e., "FooController as foo" instead of in
251
- * a separate [[controllerAs]] property.
252
- *
253
- * See: [[Ng1Controller]] for information about component-level router hooks.
254
- */
255
- controller?: IInjectable | string;
256
- /**
257
- * A controller alias name.
258
- *
259
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
260
- *
261
- * If present, the controller will be published to scope under the `controllerAs` name.
262
- * See: https://docs.angularjs.org/api/ng/directive/ngController
263
- */
264
- controllerAs?: string;
265
- /**
266
- * Dynamic controller provider function.
267
- *
268
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
269
- *
270
- * This is an injectable provider function which returns the actual controller function, or the name
271
- * of a registered controller. The provider will invoked during a Transition in which the view's state is
272
- * entered. The provider is called after the resolve data is fetched.
273
- *
274
- * #### Example:
275
- * ```js
276
- * controllerProvider: function(MyResolveData, $transition$) {
277
- * if (MyResolveData.foo) {
278
- * return "FooCtrl"
279
- * } else if ($transition$.to().name === 'bar') {
280
- * return "BarCtrl";
281
- * } else {
282
- * return function($scope) {
283
- * $scope.baz = "Qux";
284
- * }
285
- * }
286
- * }
287
- * ```
288
- */
289
- controllerProvider?: IInjectable;
290
- /**
291
- * The scope variable name to use for resolve data.
292
- *
293
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
294
- *
295
- * When a view is activated, the resolved data for the state which the view belongs to is put on the scope.
296
- * This property sets the name of the scope variable to use for the resolved data.
297
- *
298
- * Defaults to `$resolve`.
299
- */
300
- resolveAs?: string;
301
- /**
302
- * The HTML template for the view.
303
- *
304
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
305
- *
306
- * HTML template as a string, or a function which returns an html template as a string.
307
- * This template will be used to render the corresponding [[directives.uiView]] directive.
308
- *
309
- * This property takes precedence over templateUrl.
310
- *
311
- * If `template` is a function, it will be called with the Transition parameters as the first argument.
312
- *
313
- * #### Example:
314
- * ```js
315
- * template: "<h1>inline template definition</h1><div ui-view></div>"
316
- * ```
317
- *
318
- * #### Example:
319
- * ```js
320
- * template: function(params) {
321
- * return "<h1>generated template</h1>";
322
- * }
323
- * ```
324
- */
325
- template?: Function | string;
326
- /**
327
- * The URL for the HTML template for the view.
328
- *
329
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
330
- *
331
- * A path or a function that returns a path to an html template.
332
- * The template will be fetched and used to render the corresponding [[directives.uiView]] directive.
333
- *
334
- * If `templateUrl` is a function, it will be called with the Transition parameters as the first argument.
335
- *
336
- * #### Example:
337
- * ```js
338
- * templateUrl: "/templates/home.html"
339
- * ```
340
- *
341
- * #### Example:
342
- * ```js
343
- * templateUrl: function(params) {
344
- * return myTemplates[params.pageId];
345
- * }
346
- * ```
347
- */
348
- templateUrl?: string | Function;
349
- /**
350
- * Injected function which returns the HTML template.
351
- *
352
- * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
353
- *
354
- * Injected function which returns the HTML template.
355
- * The template will be used to render the corresponding [[directives.uiView]] directive.
356
- *
357
- * #### Example:
358
- * ```js
359
- * templateProvider: function(MyTemplateService, $transition$) {
360
- * return MyTemplateService.getTemplate($transition$.params().pageId);
361
- * }
362
- * ```
363
- */
364
- templateProvider?: IInjectable;
131
+ /**
132
+ * The name of the component to use for this view.
133
+ *
134
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
135
+ *
136
+ * The name of an [angular 1.5+ `.component()`](https://docs.angularjs.org/guide/component) (or directive with
137
+ * bindToController and/or scope declaration) which will be used for this view.
138
+ *
139
+ * Resolve data can be provided to the component via the component's `bindings` object (for 1.3+ directives, the
140
+ * `bindToController` is used; for other directives, the `scope` declaration is used). For each binding declared
141
+ * on the component, any resolve with the same name is set on the component's controller instance. The binding
142
+ * is provided to the component as a one-time-binding. In general, components should likewise declare their
143
+ * input bindings as [one-way ("&lt;")](https://docs.angularjs.org/api/ng/service/$compile#-scope-).
144
+ *
145
+ * Note: inside a "views:" block, a bare string `"foo"` is shorthand for `{ component: "foo" }`
146
+ *
147
+ * Note: Mapping from resolve names to component inputs may be specified using [[bindings]].
148
+ *
149
+ * #### Example:
150
+ * ```js
151
+ * .state('profile', {
152
+ * // Use the <my-profile></my-profile> component for the Unnamed view
153
+ * component: 'MyProfile',
154
+ * }
155
+ *
156
+ * .state('messages', {
157
+ * // use the <nav-bar></nav-bar> component for the view named 'header'
158
+ * // use the <message-list></message-list> component for the view named 'content'
159
+ * views: {
160
+ * header: { component: 'NavBar' },
161
+ * content: { component: 'MessageList' }
162
+ * }
163
+ * }
164
+ *
165
+ * .state('contacts', {
166
+ * // Inside a "views:" block, a bare string "NavBar" is shorthand for { component: "NavBar" }
167
+ * // use the <nav-bar></nav-bar> component for the view named 'header'
168
+ * // use the <contact-list></contact-list> component for the view named 'content'
169
+ * views: {
170
+ * header: 'NavBar',
171
+ * content: 'ContactList'
172
+ * }
173
+ * }
174
+ * ```
175
+ *
176
+ *
177
+ * Note: When using `component` to define a view, you may _not_ use any of: `template`, `templateUrl`,
178
+ * `templateProvider`, `controller`, `controllerProvider`, `controllerAs`.
179
+ *
180
+ *
181
+ * See also: Todd Motto's angular 1.3 and 1.4 [backport of .component()](https://github.com/toddmotto/angular-component)
182
+ */
183
+ component?: string;
184
+ /**
185
+ * An object which maps `resolve`s to [[component]] `bindings`.
186
+ *
187
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
188
+ *
189
+ * When using a [[component]] declaration (`component: 'myComponent'`), each input binding for the component is supplied
190
+ * data from a resolve of the same name, by default. You may supply data from a different resolve name by mapping it here.
191
+ *
192
+ * Each key in this object is the name of one of the component's input bindings.
193
+ * Each value is the name of the resolve that should be provided to that binding.
194
+ *
195
+ * Any component bindings that are omitted from this map get the default behavior of mapping to a resolve of the
196
+ * same name.
197
+ *
198
+ * #### Example:
199
+ * ```js
200
+ * $stateProvider.state('foo', {
201
+ * resolve: {
202
+ * foo: function(FooService) { return FooService.get(); },
203
+ * bar: function(BarService) { return BarService.get(); }
204
+ * },
205
+ * component: 'Baz',
206
+ * // The component's `baz` binding gets data from the `bar` resolve
207
+ * // The component's `foo` binding gets data from the `foo` resolve (default behavior)
208
+ * bindings: {
209
+ * baz: 'bar'
210
+ * }
211
+ * });
212
+ *
213
+ * app.component('Baz', {
214
+ * templateUrl: 'baz.html',
215
+ * controller: 'BazController',
216
+ * bindings: {
217
+ * foo: '<', // foo binding
218
+ * baz: '<' // baz binding
219
+ * }
220
+ * });
221
+ * ```
222
+ *
223
+ */
224
+ bindings?: {
225
+ [key: string]: string;
226
+ };
227
+ /**
228
+ * Dynamic component provider function.
229
+ *
230
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
231
+ *
232
+ * This is an injectable provider function which returns the name of the component to use.
233
+ * The provider will invoked during a Transition in which the view's state is entered.
234
+ * The provider is called after the resolve data is fetched.
235
+ *
236
+ * #### Example:
237
+ * ```js
238
+ * componentProvider: function(MyResolveData, $transition$) {
239
+ * if (MyResolveData.foo) {
240
+ * return "fooComponent"
241
+ * } else if ($transition$.to().name === 'bar') {
242
+ * return "barComponent";
243
+ * }
244
+ * }
245
+ * ```
246
+ */
247
+ componentProvider?: IInjectable;
248
+ /**
249
+ * The view's controller function or name
250
+ *
251
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
252
+ *
253
+ * The controller function, or the name of a registered controller. The controller function will be used
254
+ * to control the contents of the [[directives.uiView]] directive.
255
+ *
256
+ * If specified as a string, controllerAs can be declared here, i.e., "FooController as foo" instead of in
257
+ * a separate [[controllerAs]] property.
258
+ *
259
+ * See: [[Ng1Controller]] for information about component-level router hooks.
260
+ */
261
+ controller?: IInjectable | string;
262
+ /**
263
+ * A controller alias name.
264
+ *
265
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
266
+ *
267
+ * If present, the controller will be published to scope under the `controllerAs` name.
268
+ * See: https://docs.angularjs.org/api/ng/directive/ngController
269
+ */
270
+ controllerAs?: string;
271
+ /**
272
+ * Dynamic controller provider function.
273
+ *
274
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
275
+ *
276
+ * This is an injectable provider function which returns the actual controller function, or the name
277
+ * of a registered controller. The provider will invoked during a Transition in which the view's state is
278
+ * entered. The provider is called after the resolve data is fetched.
279
+ *
280
+ * #### Example:
281
+ * ```js
282
+ * controllerProvider: function(MyResolveData, $transition$) {
283
+ * if (MyResolveData.foo) {
284
+ * return "FooCtrl"
285
+ * } else if ($transition$.to().name === 'bar') {
286
+ * return "BarCtrl";
287
+ * } else {
288
+ * return function($scope) {
289
+ * $scope.baz = "Qux";
290
+ * }
291
+ * }
292
+ * }
293
+ * ```
294
+ */
295
+ controllerProvider?: IInjectable;
296
+ /**
297
+ * The scope variable name to use for resolve data.
298
+ *
299
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
300
+ *
301
+ * When a view is activated, the resolved data for the state which the view belongs to is put on the scope.
302
+ * This property sets the name of the scope variable to use for the resolved data.
303
+ *
304
+ * Defaults to `$resolve`.
305
+ */
306
+ resolveAs?: string;
307
+ /**
308
+ * The HTML template for the view.
309
+ *
310
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
311
+ *
312
+ * HTML template as a string, or a function which returns an html template as a string.
313
+ * This template will be used to render the corresponding [[directives.uiView]] directive.
314
+ *
315
+ * This property takes precedence over templateUrl.
316
+ *
317
+ * If `template` is a function, it will be called with the Transition parameters as the first argument.
318
+ *
319
+ * #### Example:
320
+ * ```js
321
+ * template: "<h1>inline template definition</h1><div ui-view></div>"
322
+ * ```
323
+ *
324
+ * #### Example:
325
+ * ```js
326
+ * template: function(params) {
327
+ * return "<h1>generated template</h1>";
328
+ * }
329
+ * ```
330
+ */
331
+ template?: Function | string;
332
+ /**
333
+ * The URL for the HTML template for the view.
334
+ *
335
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
336
+ *
337
+ * A path or a function that returns a path to an html template.
338
+ * The template will be fetched and used to render the corresponding [[directives.uiView]] directive.
339
+ *
340
+ * If `templateUrl` is a function, it will be called with the Transition parameters as the first argument.
341
+ *
342
+ * #### Example:
343
+ * ```js
344
+ * templateUrl: "/templates/home.html"
345
+ * ```
346
+ *
347
+ * #### Example:
348
+ * ```js
349
+ * templateUrl: function(params) {
350
+ * return myTemplates[params.pageId];
351
+ * }
352
+ * ```
353
+ */
354
+ templateUrl?: string | Function;
355
+ /**
356
+ * Injected function which returns the HTML template.
357
+ *
358
+ * A property of [[Ng1StateDeclaration]] or [[Ng1ViewDeclaration]]:
359
+ *
360
+ * Injected function which returns the HTML template.
361
+ * The template will be used to render the corresponding [[directives.uiView]] directive.
362
+ *
363
+ * #### Example:
364
+ * ```js
365
+ * templateProvider: function(MyTemplateService, $transition$) {
366
+ * return MyTemplateService.getTemplate($transition$.params().pageId);
367
+ * }
368
+ * ```
369
+ */
370
+ templateProvider?: IInjectable;
365
371
  }
366
372
  /**
367
373
  * The shape of a controller for a view (and/or component), defining the controller callbacks.
@@ -377,81 +383,81 @@ export interface Ng1ViewDeclaration extends _ViewDeclaration {
377
383
  *
378
384
  */
379
385
  export interface Ng1Controller {
380
- /** @hidden */
381
- $onInit(): void;
382
- /**
383
- * This callback is called when parameter values have changed.
384
- *
385
- * This callback can be used to respond to changing parameter values in the current state, or in parent/child states.
386
- * This callback is especially handy when using dynamic parameters ([[ParamDeclaration.dynamic]])
387
- *
388
- * Called when:
389
- * - The view is still active
390
- * - A new transition has completed successfully
391
- * - The state for the view (controller) was not reloaded
392
- * - At least one parameter value was changed
393
- *
394
- * Called with:
395
- * @param newValues an object containing the changed parameter values
396
- * @param $transition$ the new Transition which triggered this callback
397
- *
398
- * #### Example:
399
- * ```js
400
- * angular.module('foo').controller('FancyCtrl', function() {
401
- * this.uiOnParamsChanged = function(newParams) {
402
- * console.log("new params: ", newParams);
403
- * }
404
- * });
405
- * ```
406
- */
407
- uiOnParamsChanged(newValues: any, $transition$: Transition): void;
408
- /**
409
- * This callback is called when the view's state is about to be exited.
410
- *
411
- * This callback is used to inform a view that it is about to be exited, due to a new [[Transition]].
412
- * The callback can ask for user confirmation, and cancel or alter the new Transition. The callback should
413
- * return a value, or a promise for a value. If a promise is returned, the new Transition waits until the
414
- * promise settles.
415
- *
416
- *
417
- * Called when:
418
- * - The view is still active
419
- * - A new Transition is about to run
420
- * - The new Transition will exit the view's state
421
- *
422
- * Called with:
423
- * - The new Transition
424
- *
425
- * Relevant return Values:
426
- * - `false`: The transition is cancelled.
427
- * - A rejected promise: The transition is cancelled.
428
- * - [[TargetState]]: The transition is redirected to the new target state.
429
- * - Anything else: the transition will continue normally (the state and view will be deactivated)
430
- *
431
- * #### Example:
432
- * ```js
433
- * app.component('myComponent', {
434
- * template: '<input ng-model="$ctrl.data" type="text">',
435
- * bindings: { 'data': '<' },
436
- * controller: function() {
437
- *
438
- * this.originalData = angular.copy(this.data);
439
- *
440
- * this.uiCanExit = function() {
441
- * if (!angular.equals(this.data, this.originalData)) {
442
- * // Note: This could also return a Promise and request async
443
- * // confirmation using something like ui-bootstrap $modal
444
- * return window.confirm("Data has changed. Exit anyway and lose changes?");
445
- * }
446
- * }
447
- * }
448
- * }
449
- * ```
450
- *
451
- * @param transition the new Transition that is about to exit the component's state
452
- * @return a HookResult, or a promise for a HookResult
453
- */
454
- uiCanExit(transition: Transition): HookResult;
386
+ /** @hidden */
387
+ $onInit(): void;
388
+ /**
389
+ * This callback is called when parameter values have changed.
390
+ *
391
+ * This callback can be used to respond to changing parameter values in the current state, or in parent/child states.
392
+ * This callback is especially handy when using dynamic parameters ([[ParamDeclaration.dynamic]])
393
+ *
394
+ * Called when:
395
+ * - The view is still active
396
+ * - A new transition has completed successfully
397
+ * - The state for the view (controller) was not reloaded
398
+ * - At least one parameter value was changed
399
+ *
400
+ * Called with:
401
+ * @param newValues an object containing the changed parameter values
402
+ * @param $transition$ the new Transition which triggered this callback
403
+ *
404
+ * #### Example:
405
+ * ```js
406
+ * angular.module('foo').controller('FancyCtrl', function() {
407
+ * this.uiOnParamsChanged = function(newParams) {
408
+ * console.log("new params: ", newParams);
409
+ * }
410
+ * });
411
+ * ```
412
+ */
413
+ uiOnParamsChanged(newValues: any, $transition$: Transition): void;
414
+ /**
415
+ * This callback is called when the view's state is about to be exited.
416
+ *
417
+ * This callback is used to inform a view that it is about to be exited, due to a new [[Transition]].
418
+ * The callback can ask for user confirmation, and cancel or alter the new Transition. The callback should
419
+ * return a value, or a promise for a value. If a promise is returned, the new Transition waits until the
420
+ * promise settles.
421
+ *
422
+ *
423
+ * Called when:
424
+ * - The view is still active
425
+ * - A new Transition is about to run
426
+ * - The new Transition will exit the view's state
427
+ *
428
+ * Called with:
429
+ * - The new Transition
430
+ *
431
+ * Relevant return Values:
432
+ * - `false`: The transition is cancelled.
433
+ * - A rejected promise: The transition is cancelled.
434
+ * - [[TargetState]]: The transition is redirected to the new target state.
435
+ * - Anything else: the transition will continue normally (the state and view will be deactivated)
436
+ *
437
+ * #### Example:
438
+ * ```js
439
+ * app.component('myComponent', {
440
+ * template: '<input ng-model="$ctrl.data" type="text">',
441
+ * bindings: { 'data': '<' },
442
+ * controller: function() {
443
+ *
444
+ * this.originalData = angular.copy(this.data);
445
+ *
446
+ * this.uiCanExit = function() {
447
+ * if (!angular.equals(this.data, this.originalData)) {
448
+ * // Note: This could also return a Promise and request async
449
+ * // confirmation using something like ui-bootstrap $modal
450
+ * return window.confirm("Data has changed. Exit anyway and lose changes?");
451
+ * }
452
+ * }
453
+ * }
454
+ * }
455
+ * ```
456
+ *
457
+ * @param transition the new Transition that is about to exit the component's state
458
+ * @return a HookResult, or a promise for a HookResult
459
+ */
460
+ uiCanExit(transition: Transition): HookResult;
455
461
  }
456
462
  /**
457
463
  * Manages which template-loading mechanism to use.
@@ -459,33 +465,37 @@ export interface Ng1Controller {
459
465
  * Defaults to `$templateRequest` on Angular versions starting from 1.3, `$http` otherwise.
460
466
  */
461
467
  export interface TemplateFactoryProvider {
462
- /**
463
- * Forces $templateFactory to use $http instead of $templateRequest.
464
- *
465
- * UI-Router uses `$templateRequest` by default on angular 1.3+.
466
- * Use this method to choose to use `$http` instead.
467
- *
468
- * ---
469
- *
470
- * ## Security warning
471
- *
472
- * This might cause XSS, as $http doesn't enforce the regular security checks for
473
- * templates that have been introduced in Angular 1.3.
474
- *
475
- * See the $sce documentation, section
476
- * <a href="https://docs.angularjs.org/api/ng/service/$sce#impact-on-loading-templates">
477
- * Impact on loading templates</a> for more details about this mechanism.
478
- *
479
- * *Note: forcing this to `false` on Angular 1.2.x will crash, because `$templateRequest` is not implemented.*
480
- *
481
- * @param useUnsafeHttpService `true` to use `$http` to fetch templates
482
- */
483
- useHttpService(useUnsafeHttpService: boolean): any;
468
+ /**
469
+ * Forces $templateFactory to use $http instead of $templateRequest.
470
+ *
471
+ * UI-Router uses `$templateRequest` by default on angular 1.3+.
472
+ * Use this method to choose to use `$http` instead.
473
+ *
474
+ * ---
475
+ *
476
+ * ## Security warning
477
+ *
478
+ * This might cause XSS, as $http doesn't enforce the regular security checks for
479
+ * templates that have been introduced in Angular 1.3.
480
+ *
481
+ * See the $sce documentation, section
482
+ * <a href="https://docs.angularjs.org/api/ng/service/$sce#impact-on-loading-templates">
483
+ * Impact on loading templates</a> for more details about this mechanism.
484
+ *
485
+ * *Note: forcing this to `false` on Angular 1.2.x will crash, because `$templateRequest` is not implemented.*
486
+ *
487
+ * @param useUnsafeHttpService `true` to use `$http` to fetch templates
488
+ */
489
+ useHttpService(useUnsafeHttpService: boolean): any;
484
490
  }
485
- declare module '@uirouter/core/lib/state/stateRegistry' {
486
- interface StateRegistry {
487
- register(state: Ng1StateDeclaration | {
491
+ declare module "@uirouter/core/lib/state/stateRegistry" {
492
+ interface StateRegistry {
493
+ register(
494
+ state:
495
+ | Ng1StateDeclaration
496
+ | {
488
497
  new (): Ng1StateDeclaration;
489
- }): any;
490
- }
498
+ },
499
+ ): any;
500
+ }
491
501
  }