Skip to content

Commit 44dfdec

Browse files
chore(ng2): Rename UIROUTER_(PROVIDER|DIRECTIVE)S for deprecation warnings
1 parent 58a3c84 commit 44dfdec

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

src/ng2/directives/directives.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ export * from "./uiSref";
1717
export * from "./uiSrefStatus";
1818
export * from "./uiSrefActive";
1919

20+
export const _UIROUTER_DIRECTIVES = [UISref, AnchorUISref, UIView, UISrefActive, UISrefStatus];
21+
2022
/**
2123
* References to the UI-Router directive classes, for use within a @Component's `directives:` property
2224
* @deprecated use [[UIRouterModule]]
2325
*/
24-
export let UIROUTER_DIRECTIVES = [UISref, AnchorUISref, UIView, UISrefActive, UISrefStatus];
26+
export const UIROUTER_DIRECTIVES = _UIROUTER_DIRECTIVES;

src/ng2/providers.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,7 @@ let uiRouterFactory = (injector: Injector) => {
138138
return router;
139139
};
140140

141-
/**
142-
* The UI-Router providers, for use in your application bootstrap
143-
*
144-
* @deprecated use [[UIRouterModule]]
145-
*/
146-
export const UIROUTER_PROVIDERS: ProviderLike[] = [
141+
export const _UIROUTER_PROVIDERS: ProviderLike[] = [
147142
{ provide: UIRouterLocation, useClass: UIRouterLocation },
148143
{ provide: UIRouter, useFactory: uiRouterFactory, deps: [Injector] },
149144

@@ -156,4 +151,10 @@ export const UIROUTER_PROVIDERS: ProviderLike[] = [
156151
{ provide: Globals, useFactory: (r: UIRouter) => r.globals , deps: [UIRouter]},
157152

158153
{ provide: UIView.PARENT_INJECT, useFactory: (r: StateRegistry) => { return { fqn: null, context: r.root() } as ParentUIViewInject }, deps: [StateRegistry]}
159-
];
154+
]
155+
/**
156+
* The UI-Router providers, for use in your application bootstrap
157+
*
158+
* @deprecated use [[UIRouterModule]]
159+
*/
160+
export const UIROUTER_PROVIDERS = _UIROUTER_PROVIDERS;

src/ng2/uiRouterNgModule.ts

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {Ng2StateDeclaration} from "./interface";
22
import {NgModule, NgModuleMetadataType, OpaqueToken} from "@angular/core";
3-
import {UIROUTER_DIRECTIVES} from "./directives/directives";
4-
import {UIROUTER_PROVIDERS} from "./providers";
3+
import {_UIROUTER_DIRECTIVES} from "./directives/directives";
4+
import {_UIROUTER_PROVIDERS} from "./providers";
55
import {UIView} from "./directives/uiView";
66
import {uniqR, flattenR} from "../common/common";
77

88
@NgModule({
9-
declarations: [UIROUTER_DIRECTIVES],
10-
exports: [UIROUTER_DIRECTIVES],
9+
declarations: [_UIROUTER_DIRECTIVES],
10+
exports: [_UIROUTER_DIRECTIVES],
1111
entryComponents: [UIView],
12-
providers: [UIROUTER_PROVIDERS]
12+
providers: [_UIROUTER_PROVIDERS]
1313
})
1414
export class UIRouterRootModule {}
1515

@@ -39,12 +39,31 @@ export const UIROUTER_STATES_TOKEN = new OpaqueToken("UIRouter States");
3939
*
4040
* var homeState = { name: 'home', url: '/home', component: Home };
4141
* var aboutState = { name: 'about', url: '/about', component: About };
42+
*
4243
* @UIRouterModule({
4344
* imports: [BrowserModule],
4445
* declarations: [NonRoutedComponent],
4546
* states: [homeState, aboutState]
4647
* }) export class AppModule {};
4748
* ```
49+
*
50+
* The `UIRouterModule` decorator creates an Angular 2 `NgModule`.
51+
* The equivalent `AppModule` could also be crafted by hand using the `NgModule` decorator:
52+
*
53+
* ```
54+
* var homeState = { name: 'home', url: '/home', component: Home };
55+
* var aboutState = { name: 'about', url: '/about', component: About };
56+
*
57+
* @NgModule({
58+
* imports: [BrowserModule, UIRouterRootModule],
59+
* declarations: [NonRoutedComponent, Home, About],
60+
* entryComponents: [Home, About],
61+
* providers: [
62+
* { provide: UIROUTER_STATES_TOKEN, useValue: [homeState, aboutState], multi: true }
63+
* ]
64+
* }) export class AppModule {};
65+
*
66+
* ```
4867
*
4968
* @param moduleMetaData the [[UIRouterModuleMetadata]]
5069
* (See also [NgModuleMetadataType](https://angular.io/docs/ts/latest/api/core/index/NgModuleMetadataType-interface.html)

0 commit comments

Comments
 (0)