1
1
/** @module ng1_directives */ /** for typedoc */
2
2
"use strict" ;
3
- import { extend , unnestR , filter } from "../../common/common" ;
3
+ import { extend , unnestR , filter , tail } from "../../common/common" ;
4
4
import { isDefined , isFunction , isString } from "../../common/predicates" ;
5
5
import { trace } from "../../common/trace" ;
6
6
import { ActiveUIView } from "../../view/interface" ;
@@ -13,7 +13,7 @@ import {PathNode} from "../../path/node";
13
13
import { Param } from "../../params/param" ;
14
14
import { kebobString } from "../../common/strings" ;
15
15
import { HookRegOptions } from "../../transition/interface" ;
16
- import { Ng1Controller } from "../interface" ;
16
+ import { Ng1Controller , Ng1StateDeclaration } from "../interface" ;
17
17
import { getLocals } from "../services" ;
18
18
19
19
/** @hidden */
@@ -315,7 +315,6 @@ $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view'
315
315
function $ViewDirectiveFill ( $compile , $controller , $transitions , $view , $timeout ) {
316
316
const getControllerAs = parse ( 'viewDecl.controllerAs' ) ;
317
317
const getResolveAs = parse ( 'viewDecl.resolveAs' ) ;
318
- const getResolveContext = parse ( 'node.resolveContext' ) ;
319
318
320
319
return {
321
320
restrict : 'ECA' ,
@@ -335,8 +334,7 @@ function $ViewDirectiveFill ( $compile, $controller, $transitions, $view,
335
334
let controller = cfg . controller ;
336
335
let controllerAs : string = getControllerAs ( cfg ) ;
337
336
let resolveAs : string = getResolveAs ( cfg ) ;
338
- let resolveCtx : ResolveContext = getResolveContext ( cfg ) ;
339
-
337
+ let resolveCtx : ResolveContext = cfg . path && new ResolveContext ( cfg . path ) ;
340
338
let locals = resolveCtx && getLocals ( resolveCtx ) ;
341
339
342
340
scope [ resolveAs ] = locals ;
@@ -390,16 +388,19 @@ function registerControllerCallbacks($transitions: TransitionService, controller
390
388
// Call $onInit() ASAP
391
389
if ( isFunction ( controllerInstance . $onInit ) && ! ( cfg . viewDecl . component && hasComponentImpl ) ) controllerInstance . $onInit ( ) ;
392
390
391
+ let viewState : Ng1StateDeclaration = tail ( cfg . path ) . state . self ;
392
+
393
393
var hookOptions : HookRegOptions = { bind : controllerInstance } ;
394
394
// Add component-level hook for onParamsChange
395
395
if ( isFunction ( controllerInstance . uiOnParamsChanged ) ) {
396
+ let resolveContext : ResolveContext = new ResolveContext ( cfg . path ) ;
397
+ let viewCreationTrans = resolveContext . getResolvable ( '$transition$' ) . data ;
398
+
396
399
// Fire callback on any successful transition
397
400
const paramsUpdated = ( $transition$ : Transition ) => {
398
- let ctx : ResolveContext = cfg . node . resolveContext ;
399
- let viewCreationTrans = ctx . getResolvable ( '$transition$' ) . data ;
400
401
// Exit early if the $transition$ is the same as the view was created within.
401
402
// 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 ;
403
404
404
405
let toParams = $transition$ . params ( "to" ) ;
405
406
let fromParams = $transition$ . params ( "from" ) ;
@@ -424,7 +425,7 @@ function registerControllerCallbacks($transitions: TransitionService, controller
424
425
425
426
// Add component-level hook for uiCanExit
426
427
if ( isFunction ( controllerInstance . uiCanExit ) ) {
427
- var criteria = { exiting : cfg . node . state . name } ;
428
+ var criteria = { exiting : viewState . name } ;
428
429
$scope . $on ( '$destroy' , $transitions . onBefore ( criteria , controllerInstance . uiCanExit , hookOptions ) ) ;
429
430
}
430
431
}
0 commit comments