Skip to content

Commit e9705b0

Browse files
feat(config): Pass the module object to the module config function
``` export function routerConfig(router: UIRouter, injector: Injector, module: StatesModule) { } ... @UIRouterModule.forRoot({ states: STATES, config: routerConfig }); ... ``` Closes #55
1 parent c894fbc commit e9705b0

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/uiRouterConfig.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import {StatesModule, RootModule} from "./uiRouterNgModule";
44
import {Injector} from "@angular/core";
55
import {isDefined} from "ui-router-core";
66

7-
export function applyModuleConfig(uiRouter: UIRouter, injector: Injector, options: StatesModule = {}): StateObject[] {
8-
if (isFunction(options.config)) {
9-
options.config(uiRouter, injector, options);
7+
export function applyModuleConfig(uiRouter: UIRouter, injector: Injector, module: StatesModule = {}): StateObject[] {
8+
if (isFunction(module.config)) {
9+
module.config(uiRouter, injector, module);
1010
}
1111

12-
let states = options.states || [];
12+
let states = module.states || [];
1313
return states.map(state => uiRouter.stateRegistry.register(state));
1414
}
1515

16-
export function applyRootModuleConfig(uiRouter: UIRouter, injector: Injector, config: RootModule) {
17-
isDefined(config.deferIntercept) && uiRouter.urlService.deferIntercept(config.deferIntercept);
18-
isDefined(config.otherwise) && uiRouter.urlService.rules.otherwise(config.otherwise);
16+
export function applyRootModuleConfig(uiRouter: UIRouter, injector: Injector, module: RootModule) {
17+
isDefined(module.deferIntercept) && uiRouter.urlService.deferIntercept(module.deferIntercept);
18+
isDefined(module.otherwise) && uiRouter.urlService.rules.otherwise(module.otherwise);
1919
}
2020

2121

src/uiRouterNgModule.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ export interface StatesModule {
191191
*
192192
* If a UI-Router Module needs to perform some configuration (such as registering
193193
* parameter types or Transition Hooks) a `configFn` should be supplied.
194-
* The function will be passed the `UIRouter` instance and the module's `Injector`
194+
* The function will be passed the `UIRouter` instance, the module's `Injector`,
195+
* and the module object.
195196
*
196197
* #### Example:
197198
* ```js
@@ -200,7 +201,7 @@ export interface StatesModule {
200201
* import { requireAuthHook } from "./requireAuthHook";
201202
* import { MyService } from "./myService";
202203
*
203-
* export function configureMyModule(uiRouter: UIRouter, injector: Injector, options: StatesModule) {
204+
* export function configureMyModule(uiRouter: UIRouter, injector: Injector, module: StatesModule) {
204205
* // Get UIRouter services off the UIRouter object
205206
* let urlConfig = uiRouter.urlService.config;
206207
* let transitionService = uiRouter.transitionService;
@@ -228,6 +229,6 @@ export interface StatesModule {
228229
* class MyModule {}
229230
* ```
230231
*/
231-
config?: (uiRouterInstance: UIRouter, injector: Injector, options: StatesModule) => any;
232+
config?: (uiRouterInstance: UIRouter, injector: Injector, module: StatesModule) => any;
232233
}
233234

0 commit comments

Comments
 (0)