11/** @module ng1_directives */ /** for typedoc */
22"use strict" ;
3- import { extend , unnestR , filter } from "../../common/common" ;
3+ import { extend , unnestR , filter , tail } from "../../common/common" ;
44import { isDefined , isFunction , isString } from "../../common/predicates" ;
55import { trace } from "../../common/trace" ;
66import { ActiveUIView } from "../../view/interface" ;
@@ -13,7 +13,7 @@ import {PathNode} from "../../path/node";
1313import { Param } from "../../params/param" ;
1414import { kebobString } from "../../common/strings" ;
1515import { HookRegOptions } from "../../transition/interface" ;
16- import { Ng1Controller } from "../interface" ;
16+ import { Ng1Controller , Ng1StateDeclaration } from "../interface" ;
1717import { getLocals } from "../services" ;
1818
1919/** @hidden */
@@ -315,7 +315,6 @@ $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view'
315315function $ViewDirectiveFill ( $compile , $controller , $transitions , $view , $timeout ) {
316316 const getControllerAs = parse ( 'viewDecl.controllerAs' ) ;
317317 const getResolveAs = parse ( 'viewDecl.resolveAs' ) ;
318- const getResolveContext = parse ( 'node.resolveContext' ) ;
319318
320319 return {
321320 restrict : 'ECA' ,
@@ -335,8 +334,7 @@ function $ViewDirectiveFill ( $compile, $controller, $transitions, $view,
335334 let controller = cfg . controller ;
336335 let controllerAs : string = getControllerAs ( cfg ) ;
337336 let resolveAs : string = getResolveAs ( cfg ) ;
338- let resolveCtx : ResolveContext = getResolveContext ( cfg ) ;
339-
337+ let resolveCtx : ResolveContext = cfg . path && new ResolveContext ( cfg . path ) ;
340338 let locals = resolveCtx && getLocals ( resolveCtx ) ;
341339
342340 scope [ resolveAs ] = locals ;
@@ -390,16 +388,19 @@ function registerControllerCallbacks($transitions: TransitionService, controller
390388 // Call $onInit() ASAP
391389 if ( isFunction ( controllerInstance . $onInit ) && ! ( cfg . viewDecl . component && hasComponentImpl ) ) controllerInstance . $onInit ( ) ;
392390
391+ let viewState : Ng1StateDeclaration = tail ( cfg . path ) . state . self ;
392+
393393 var hookOptions : HookRegOptions = { bind : controllerInstance } ;
394394 // Add component-level hook for onParamsChange
395395 if ( isFunction ( controllerInstance . uiOnParamsChanged ) ) {
396+ let resolveContext : ResolveContext = new ResolveContext ( cfg . path ) ;
397+ let viewCreationTrans = resolveContext . getResolvable ( '$transition$' ) . data ;
398+
396399 // Fire callback on any successful transition
397400 const paramsUpdated = ( $transition$ : Transition ) => {
398- let ctx : ResolveContext = cfg . node . resolveContext ;
399- let viewCreationTrans = ctx . getResolvable ( '$transition$' ) . data ;
400401 // Exit early if the $transition$ is the same as the view was created within.
401402 // Exit early if the $transition$ will exit the state the view is for.
402- if ( $transition$ === viewCreationTrans || $transition$ . exiting ( ) . indexOf ( cfg . node . state . self ) !== - 1 ) return ;
403+ if ( $transition$ === viewCreationTrans || $transition$ . exiting ( ) . indexOf ( viewState ) !== - 1 ) return ;
403404
404405 let toParams = $transition$ . params ( "to" ) ;
405406 let fromParams = $transition$ . params ( "from" ) ;
@@ -424,7 +425,7 @@ function registerControllerCallbacks($transitions: TransitionService, controller
424425
425426 // Add component-level hook for uiCanExit
426427 if ( isFunction ( controllerInstance . uiCanExit ) ) {
427- var criteria = { exiting : cfg . node . state . name } ;
428+ var criteria = { exiting : viewState . name } ;
428429 $scope . $on ( '$destroy' , $transitions . onBefore ( criteria , controllerInstance . uiCanExit , hookOptions ) ) ;
429430 }
430431}
0 commit comments