Skip to content

Commit

Permalink
refactor(otherwise): Switch otherwise to passthrough (ui-router-core …
Browse files Browse the repository at this point in the history
…3.1.0 API)
  • Loading branch information
christopherthielen committed Jan 14, 2017
1 parent a1855ab commit cb7f51f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
17 changes: 2 additions & 15 deletions src/ng2/uiRouterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,8 @@ export function applyModuleConfig(uiRouter: UIRouter, injector: Injector, option
}

export function applyRootModuleConfig(uiRouter: UIRouter, injector: Injector, config: RootModule) {
if (isDefined(config.deferIntercept)) {
uiRouter.urlRouterProvider.deferIntercept(config.deferIntercept);
}

if (isDefined(config.otherwise)) {
if (isDefined(config.otherwise['state'])) {
uiRouter.urlRouterProvider.otherwise(function() {
let { state, params } = <any> config.otherwise;
uiRouter.stateService.go(state, params, { source: "otherwise" });
return null;
});
} else {
uiRouter.urlRouterProvider.otherwise(<any> config.otherwise);
}
}
isDefined(config.deferIntercept) && uiRouter.urlService.deferIntercept(config.deferIntercept);
isDefined(config.otherwise) && uiRouter.urlService.rules.otherwise(config.otherwise);
}


23 changes: 12 additions & 11 deletions src/ng2/uiRouterNgModule.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/** @ng2api @module core */ /** */
import {Ng2StateDeclaration} from "./interface";
import {NgModule, OpaqueToken, ModuleWithProviders, ANALYZE_FOR_ENTRY_COMPONENTS, Provider, Type} from "@angular/core";
import {CommonModule} from "@angular/common";
import {_UIROUTER_DIRECTIVES} from "./directives/directives";
import {UIView} from "./directives/uiView";
import {RawParams} from "ui-router-core";
import {identity} from "ui-router-core";
import {LocationStrategy, HashLocationStrategy, PathLocationStrategy} from "@angular/common";
import {_UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS} from "./providers";
/** @ng2api @module core */
/** */
import { Ng2StateDeclaration } from "./interface";
import {
NgModule, OpaqueToken, ModuleWithProviders, ANALYZE_FOR_ENTRY_COMPONENTS, Provider, Type
} from "@angular/core";
import { CommonModule, LocationStrategy, HashLocationStrategy, PathLocationStrategy } from "@angular/common";
import { _UIROUTER_DIRECTIVES } from "./directives/directives";
import { UIView } from "./directives/uiView";
import { UrlRuleHandlerFn, TargetState, TargetStateDef } from "ui-router-core";
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from "./providers";

export function makeRootProviders(module: StatesModule): Provider[] {
return [
Expand Down Expand Up @@ -157,7 +158,7 @@ export interface RootModule extends StatesModule {
/**
* Sets [[UrlRouterProvider.otherwise]].
*/
otherwise?: (string | Function | { state: string, params?: RawParams })
otherwise?: (string | UrlRuleHandlerFn | TargetState | TargetStateDef)

/**
* Sets [[UrlRouterProvider.deferIntercept]]
Expand Down

0 comments on commit cb7f51f

Please sign in to comment.