File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,13 @@ import { Ng1StateDeclaration } from '../interface';
1414 */
1515export const getStateHookBuilder = ( hookName : "onEnter" | "onExit" | "onRetain" ) =>
1616function stateHookBuilder ( state : StateObject , parentFn : BuilderFunction ) : TransitionStateHookFn {
17- let hook = state [ hookName ] ;
18- let pathname = hookName === 'onExit' ? 'from' : 'to' ;
17+ const hook = state [ hookName ] ;
18+ const pathname = hookName === 'onExit' ? 'from' : 'to' ;
1919
2020 function decoratedNg1Hook ( trans : Transition , state : Ng1StateDeclaration ) : HookResult {
21- let resolveContext = new ResolveContext ( trans . treeChanges ( pathname ) ) ;
22- let locals = extend ( getLocals ( resolveContext ) , { $state$ : state , $transition$ : trans } ) ;
21+ const resolveContext = new ResolveContext ( trans . treeChanges ( pathname ) ) ;
22+ const subContext = resolveContext . subContext ( state . $$state ( ) ) ;
23+ const locals = extend ( getLocals ( subContext ) , { $state$ : state , $transition$ : trans } ) ;
2324 return services . $injector . invoke ( hook , this , locals ) ;
2425 }
2526
Original file line number Diff line number Diff line change @@ -476,6 +476,30 @@ describe("Integration: Resolvables system", () => {
476476 expect ( counts . _J ) . toEqualData ( 1 ) ;
477477 } ) ;
478478
479+ it ( "should not inject child data into parent" , ( ) => {
480+ let injectedData ;
481+ router . stateRegistry . register ( {
482+ name : 'foo' ,
483+ resolve : {
484+ myresolve : ( ) => 'foodata' ,
485+ } ,
486+ onEnter : ( myresolve ) => injectedData = myresolve ,
487+ } ) ;
488+
489+ router . stateRegistry . register ( {
490+ name : 'foo.bar' ,
491+ resolve : {
492+ myresolve : ( ) => 'bardata' ,
493+ } ,
494+ } ) ;
495+
496+ $state . go ( "foo.bar" ) ;
497+ $rootScope . $digest ( ) ;
498+
499+ expect ( $state . current . name ) . toBe ( "foo.bar" ) ;
500+ expect ( injectedData ) . toBe ( 'foodata' ) ;
501+ } ) ;
502+
479503 it ( "should inject a promise for NOWAIT resolve into a controller" , inject ( function ( $compile , $rootScope ) {
480504 let scope = $rootScope . $new ( ) ;
481505 let el = $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ;
You can’t perform that action at this time.
0 commit comments