-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathinjectables.ts
400 lines (380 loc) · 13.2 KB
/
injectables.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* # Angular 1 injectable services
*
* This is a list of the objects which can be injected using angular's injector.
*
* There are three different kind of injectable objects:
*
* ## **Provider** objects
* #### injectable into a `.config()` block during configtime
*
* - [[$uiRouterProvider]]: The UI-Router instance
* - [[$stateProvider]]: State registration
* - [[$transitionsProvider]]: Transition hooks
* - [[$urlServiceProvider]]: All URL related public APIs
*
* - [[$uiViewScrollProvider]]: Disable ui-router view scrolling
* - [[$urlRouterProvider]]: (deprecated) Url matching rules
* - [[$urlMatcherFactoryProvider]]: (deprecated) Url parsing config
*
* ## **Service** objects
* #### injectable globally during runtime
*
* - [[$uiRouter]]: The UI-Router instance
* - [[$trace]]: Enable transition trace/debug
* - [[$transitions]]: Transition hooks
* - [[$state]]: Imperative state related APIs
* - [[$stateRegistry]]: State registration
* - [[$urlService]]: All URL related public APIs
* - [[$uiRouterGlobals]]: Global variables
* - [[$uiViewScroll]]: Scroll an element into view
*
* - [[$stateParams]]: (deprecated) Global state param values
* - [[$urlRouter]]: (deprecated) URL synchronization
* - [[$urlMatcherFactory]]: (deprecated) URL parsing config
*
* ## **Per-Transition** objects
*
* - These kind of objects are injectable into:
* - Resolves ([[Ng1StateDeclaration.resolve]]),
* - Transition Hooks ([[TransitionService.onStart]], etc),
* - Routed Controllers ([[Ng1ViewDeclaration.controller]])
*
* #### Different instances are injected based on the [[Transition]]
*
* - [[$transition$]]: The current Transition object
* - [[$stateParams]]: State param values for pending Transition (deprecated)
* - Any resolve data defined using [[Ng1StateDeclaration.resolve]]
*
* @preferred @publicapi @module injectables
*/ /** */
import { StateProvider } from './stateProvider';
import {
StateService,
TransitionService,
Transition,
UrlRouter,
UrlMatcherFactory,
StateParams,
StateRegistry,
UIRouterGlobals,
UIRouter,
Trace,
UrlService,
} from '@uirouter/core';
import { UIViewScrollProvider } from './viewScroll';
import { UrlRouterProvider } from './urlRouterProvider';
/**
* The current (or pending) State Parameters
*
* An injectable global **Service Object** which holds the state parameters for the latest **SUCCESSFUL** transition.
*
* The values are not updated until *after* a `Transition` successfully completes.
*
* **Also:** an injectable **Per-Transition Object** object which holds the pending state parameters for the pending `Transition` currently running.
*
* ### Deprecation warning:
*
* The value injected for `$stateParams` is different depending on where it is injected.
*
* - When injected into an angular service, the object injected is the global **Service Object** with the parameter values for the latest successful `Transition`.
* - When injected into transition hooks, resolves, or view controllers, the object is the **Per-Transition Object** with the parameter values for the running `Transition`.
*
* Because of these confusing details, this service is deprecated.
*
* ### Instead of using the global `$stateParams` service object,
* inject [[$uiRouterGlobals]] and use [[UIRouterGlobals.params]]
*
* ```js
* MyService.$inject = ['$uiRouterGlobals'];
* function MyService($uiRouterGlobals) {
* return {
* paramValues: function () {
* return $uiRouterGlobals.params;
* }
* }
* }
* ```
*
* ### Instead of using the per-transition `$stateParams` object,
* inject the current `Transition` (as [[$transition$]]) and use [[Transition.params]]
*
* ```js
* MyController.$inject = ['$transition$'];
* function MyController($transition$) {
* var username = $transition$.params().username;
* // .. do something with username
* }
* ```
*
* ---
*
* This object can be injected into other services.
*
* #### Deprecated Example:
* ```js
* SomeService.$inject = ['$http', '$stateParams'];
* function SomeService($http, $stateParams) {
* return {
* getUser: function() {
* return $http.get('/api/users/' + $stateParams.username);
* }
* }
* };
* angular.service('SomeService', SomeService);
* ```
* @deprecated
*/
let $stateParams: StateParams;
/**
* Global UI-Router variables
*
* The router global state as a **Service Object** (injectable during runtime).
*
* This object contains globals such as the current state and current parameter values.
*/
let $uiRouterGlobals: UIRouterGlobals;
/**
* The UI-Router instance
*
* The [[UIRouter]] singleton (the router instance) as a **Service Object** (injectable during runtime).
*
* This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
* It has references to the other UI-Router services
*
* #### Note: This object is also exposed as [[$uiRouterProvider]] for injection during angular config time.
*/
let $uiRouter: UIRouter;
/**
* The UI-Router instance
*
* The [[UIRouter]] singleton (the router instance) as a **Provider Object** (injectable during config phase).
*
* This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
* It has references to the other UI-Router services
*
* #### Note: This object is also exposed as [[$uiRouter]] for injection during runtime.
*/
let $uiRouterProvider: UIRouter;
/**
* Transition debug/tracing
*
* The [[Trace]] singleton as a **Service Object** (injectable during runtime).
*
* Enables or disables Transition tracing which can help to debug issues.
*/
let $trace: Trace;
/**
* The Transition Service
*
* The [[TransitionService]] singleton as a **Service Object** (injectable during runtime).
*
* This angular service exposes the [[TransitionService]] singleton, which is primarily
* used to register global transition hooks.
*
* #### Note: This object is also exposed as [[$transitionsProvider]] for injection during the config phase.
*/
let $transitions: TransitionService;
/**
* The Transition Service
*
* The [[TransitionService]] singleton as a **Provider Object** (injectable during config phase)
*
* This angular service exposes the [[TransitionService]] singleton, which is primarily
* used to register global transition hooks.
*
* #### Note: This object is also exposed as [[$transitions]] for injection during runtime.
*/
let $transitionsProvider: TransitionService;
/**
* The current [[Transition]] object
*
* The current [[Transition]] object as a **Per-Transition Object** (injectable into Resolve, Hooks, Controllers)
*
* This object returns information about the current transition, including:
*
* - To/from states
* - To/from parameters
* - Transition options
* - States being entered, exited, and retained
* - Resolve data
* - A Promise for the transition
* - Any transition failure information
* - An injector for both Service and Per-Transition Objects
*/
let $transition$: Transition;
/**
* The State Service
*
* The [[StateService]] singleton as a **Service Object** (injectable during runtime).
*
* This service used to manage and query information on registered states.
* It exposes state related APIs including:
*
* - Start a [[Transition]]
* - Imperatively lazy load states
* - Check if a state is currently active
* - Look up states by name
* - Build URLs for a state+parameters
* - Configure the global Transition error handler
*
* This angular service exposes the [[StateService]] singleton.
*/
let $state: StateService;
/**
* The State Registry
*
* The [[StateRegistry]] singleton as a **Service Object** (injectable during runtime).
*
* This service is used to register/deregister states.
* It has state registration related APIs including:
*
* - Register/deregister states
* - Listen for state registration/deregistration
* - Get states by name
* - Add state decorators (to customize the state creation process)
*
* #### Note: This object is also exposed as [[$stateRegistryProvider]] for injection during the config phase.
*/
let $stateRegistry: StateRegistry;
/**
* The State Registry
*
* The [[StateRegistry]] singleton as a **Provider Object** (injectable during config time).
*
* This service is used to register/deregister states.
* It has state registration related APIs including:
*
* - Register/deregister states
* - Listen for state registration/deregistration
* - Get states by name
* - Add state decorators (to customize the state creation process)
*
* #### Note: This object is also exposed as [[$stateRegistry]] for injection during runtime.
*/
let $stateRegistryProvider: StateRegistry;
/**
* The View Scroll provider
*
* The [[UIViewScrollProvider]] as a **Provider Object** (injectable during config time).
*
* This angular service exposes the [[UIViewScrollProvider]] singleton and is
* used to disable UI-Router's scroll behavior.
*/
let $uiViewScrollProvider: UIViewScrollProvider;
/**
* The View Scroll function
*
* The View Scroll function as a **Service Object** (injectable during runtime).
*
* This is a function that scrolls an element into view.
* The element is scrolled after a `$timeout` so the DOM has time to refresh.
*
* If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
* this can be enabled by calling [[UIViewScrollProvider.useAnchorScroll]].
*
* Note: this function is used by the [[directives.uiView]] when the `autoscroll` expression evaluates to true.
*/
let $uiViewScroll: ($element: JQuery) => void;
/**
* The StateProvider
*
* An angular1-only [[StateProvider]] as a **Provider Object** (injectable during config time).
*
* This angular service exposes the [[StateProvider]] singleton.
*
* The `StateProvider` is primarily used to register states or add custom state decorators.
*
* ##### Note: This provider is a ng1 vestige.
* It is a passthrough to [[$stateRegistry]] and [[$state]].
*/
let $stateProvider: StateProvider;
/**
* The URL Service Provider
*
* The [[UrlService]] singleton as a **Provider Object** (injectable during the angular config phase).
*
* A service used to configure and interact with the URL.
* It has URL related APIs including:
*
* - register custom Parameter types `UrlService.config.type` ([[UrlConfigApi.type]])
* - add URL rules: `UrlService.rules.when` ([[UrlRulesApi.when]])
* - configure behavior when no url matches: `UrlService.rules.otherwise` ([[UrlRulesApi.otherwise]])
* - delay initial URL synchronization [[UrlService.deferIntercept]].
* - get or set the current url: [[UrlService.url]]
*
* ##### Note: This service can also be injected during runtime as [[$urlService]].
*/
let $urlServiceProvider: UrlService;
/**
* The URL Service
*
* The [[UrlService]] singleton as a **Service Object** (injectable during runtime).
*
* Note: This service can also be injected during the config phase as [[$urlServiceProvider]].
*
* Used to configure the URL.
* It has URL related APIs including:
*
* - register custom Parameter types `UrlService.config.type` ([[UrlConfigApi.type]])
* - add URL rules: `UrlService.rules.when` ([[UrlRulesApi.when]])
* - configure behavior when no url matches: `UrlService.rules.otherwise` ([[UrlRulesApi.otherwise]])
* - delay initial URL synchronization [[UrlService.deferIntercept]].
* - get or set the current url: [[UrlService.url]]
*
* ##### Note: This service can also be injected during the config phase as [[$urlServiceProvider]].
*/
let $urlService: UrlService;
/**
* The URL Router Provider
*
* ### Deprecation warning: This object is now considered internal. Use [[$urlServiceProvider]] instead.
*
* The [[UrlRouter]] singleton as a **Provider Object** (injectable during config time).
*
* #### Note: This object is also exposed as [[$urlRouter]] for injection during runtime.
*
* @deprecated
*/
let $urlRouterProvider: UrlRouterProvider;
/**
* The Url Router
*
* ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
*
* The [[UrlRouter]] singleton as a **Service Object** (injectable during runtime).
*
* #### Note: This object is also exposed as [[$urlRouterProvider]] for injection during angular config time.
*
* @deprecated
*/
let $urlRouter: UrlRouter;
/**
* The URL Matcher Factory
*
* ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
*
* The [[UrlMatcherFactory]] singleton as a **Service Object** (injectable during runtime).
*
* This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
*
* #### Note: This object is also exposed as [[$urlMatcherFactoryProvider]] for injection during angular config time.
*
* @deprecated
*/
let $urlMatcherFactory: UrlMatcherFactory;
/**
* The URL Matcher Factory
*
* ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
*
* The [[UrlMatcherFactory]] singleton as a **Provider Object** (injectable during config time).
*
* This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
*
* #### Note: This object is also exposed as [[$urlMatcherFactory]] for injection during runtime.
*
* @deprecated
*/
let $urlMatcherFactoryProvider: UrlMatcherFactory;