From 9313880e1299c6ecd0d7a348b5e274199de4cfe5 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 14 Jan 2017 18:08:18 -0600 Subject: [PATCH] fix(lazyLoad): Allow `lazyLoad` stateBuilder: Get lazyLoad fn from internal State object, not StateDeclaration fix(lazyLoad): Fix `State.lazyLoad` type def --- src/hooks/lazyLoad.ts | 7 +++---- src/state/stateObject.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hooks/lazyLoad.ts b/src/hooks/lazyLoad.ts index 1c761b64..63903625 100644 --- a/src/hooks/lazyLoad.ts +++ b/src/hooks/lazyLoad.ts @@ -3,7 +3,6 @@ import {Transition} from "../transition/transition"; import {TransitionService} from "../transition/transitionService"; import {TransitionHookFn} from "../transition/interface"; import {StateDeclaration, LazyLoadResult} from "../state/interface"; -import {State} from "../state/stateObject"; import {services} from "../common/coreservices"; import { StateRule } from "../url/interface"; @@ -57,11 +56,11 @@ const lazyLoadHook: TransitionHookFn = (transition: Transition) => { } // No matching state found, so let .sync() choose the best non-state match/otherwise - router.urlRouter.sync(); + router.urlService.sync(); } let promises = transition.entering() - .filter(state => !!state.lazyLoad) + .filter(state => !!state.$$state().lazyLoad) .map(state => lazyLoadState(transition, state)); return services.$q.all(promises).then(retryTransition); @@ -79,7 +78,7 @@ export const registerLazyLoadHook = (transitionService: TransitionService) => * @returns A promise for the lazy load result */ export function lazyLoadState(transition: Transition, state: StateDeclaration): Promise { - let lazyLoadFn = state.lazyLoad; + let lazyLoadFn = state.$$state().lazyLoad; // Store/get the lazy load promise on/from the hookfn so it doesn't get re-invoked let promise = lazyLoadFn['_promise']; diff --git a/src/state/stateObject.ts b/src/state/stateObject.ts index 8f1a1c8b..854ac746 100644 --- a/src/state/stateObject.ts +++ b/src/state/stateObject.ts @@ -86,7 +86,7 @@ export class State { public onEnter: TransitionStateHookFn; /** Prototypally inherits from [[StateDeclaration.lazyLoad]] */ - public lazyLoad: (transition: Transition) => Promise; + public lazyLoad: (transition: Transition, state: StateDeclaration) => Promise; /** Prototypally inherits from [[StateDeclaration.redirectTo]] */ redirectTo: (