From bf263437d0c2354f1599e6951d3d27c0508b0491 Mon Sep 17 00:00:00 2001 From: mmmichl Date: Tue, 12 Apr 2016 15:47:57 +0200 Subject: [PATCH] Introduce `unfoundState` type from `$stateNotFound` event (#8894) --- angular-ui-router/angular-ui-router-tests.ts | 11 +++++++++++ angular-ui-router/angular-ui-router.d.ts | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index ba42f16cf..9c5db1754 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -141,6 +141,8 @@ class UrlLocatorTestService implements IUrlLocatorTestService { private $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); + $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => + this.onStateNotFound(event, unfoundState, fromState, fromParams)); } public currentUser: any; @@ -162,6 +164,15 @@ class UrlLocatorTestService implements IUrlLocatorTestService { }); } } + + private onStateNotFound(event: ng.IAngularEvent, + unfoundState: ng.ui.IUnfoundState, + fromState: ng.ui.IState, + fromParams: {}) { + var unfoundTo: string = unfoundState.to; + var unfoundToParams: {} = unfoundState.toParams; + var unfoundOptions: ng.ui.IStateOptions = unfoundState.options + } private stateServiceTest() { this.$state.go("myState"); diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 17d157098..051252809 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -100,6 +100,12 @@ declare namespace angular.ui { cache?: boolean; } + interface IUnfoundState { + to: string, + toParams: {}, + options: IStateOptions + } + interface IStateProvider extends angular.IServiceProvider { state(name:string, config:IState): IStateProvider; state(config:IState): IStateProvider;