-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathprovideUiRouter.ts
More file actions
37 lines (36 loc) · 1.21 KB
/
provideUiRouter.ts
File metadata and controls
37 lines (36 loc) · 1.21 KB
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
import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';
import { locationStrategy, makeRootProviders, RootModule } from './uiRouterNgModule';
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from './providers';
/**
* Sets up providers necessary to enable UI-Router for the application. Intended as a replacement
* for [[UIRouterModule.forRoot]] in newer standalone based applications.
*
* Example:
* ```js
* const routerConfig = {
* otherwise: '/home',
* states: [homeState, aboutState]
* };
*
* const appConfig: ApplicationConfig = {
* providers: [
* provideZoneChangeDetection({ eventCoalescing: true }),
* provideUIRouter(routerConfig)
* ]
* };
*
* bootstrapApplication(AppComponent, appConfig)
* .catch((err) => console.error(err));
* ```
*
* @param config declarative UI-Router configuration
* @returns an `EnvironmentProviders` which provides the [[UIRouter]] singleton instance
*/
export function provideUIRouter(config: RootModule = {}): EnvironmentProviders {
return makeEnvironmentProviders([
_UIROUTER_INSTANCE_PROVIDERS,
_UIROUTER_SERVICE_PROVIDERS,
locationStrategy(config.useHash),
...makeRootProviders(config),
]);
}