File tree 2 files changed +29
-4
lines changed
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';
14
14
*/
15
15
export const getStateHookBuilder = ( hookName : "onEnter" | "onExit" | "onRetain" ) =>
16
16
function 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' ;
19
19
20
20
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 } ) ;
23
24
return services . $injector . invoke ( hook , this , locals ) ;
24
25
}
25
26
Original file line number Diff line number Diff line change @@ -476,6 +476,30 @@ describe("Integration: Resolvables system", () => {
476
476
expect ( counts . _J ) . toEqualData ( 1 ) ;
477
477
} ) ;
478
478
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
+
479
503
it ( "should inject a promise for NOWAIT resolve into a controller" , inject ( function ( $compile , $rootScope ) {
480
504
let scope = $rootScope . $new ( ) ;
481
505
let el = $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ;
You can’t perform that action at this time.
0 commit comments