11/** @module view */ /** for typedoc */
2+ "use strict" ;
23import { extend , map } from "../common/common" ;
34import { isDefined , isFunction } from "../common/predicates" ;
45import { trace } from "../common/trace" ;
56import { ActiveUIView } from "../view/interface" ;
67import { Ng1ViewConfig } from "./viewsBuilder" ;
8+ import { RejectType } from "../transition/rejectFactory" ;
9+ import { TransitionService } from "../transition/transitionService" ;
10+ import { parse } from "../common/hof" ;
11+ import { ResolveContext } from "../resolve/resolveContext" ;
712
813export type UIViewData = {
914 $cfg : Ng1ViewConfig ;
@@ -174,7 +179,7 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
174179 }
175180
176181 let rootData = {
177- $cfg : { context : $view . rootContext ( ) } ,
182+ $cfg : { viewDecl : { $ context : $view . rootContext ( ) } } ,
178183 $uiView : { }
179184 } ;
180185
@@ -201,7 +206,9 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
201206 fqn : inherited . $uiView . fqn ? inherited . $uiView . fqn + "." + name : name , // fully qualified name, describes location in DOM
202207 config : null , // The ViewConfig loaded (from a state.views definition)
203208 configUpdated : configUpdatedCallback , // Called when the matching ViewConfig changes
204- get creationContext ( ) { return inherited . $cfg . context ; } // The context in which this ui-view "tag" was created
209+ get creationContext ( ) { // The context in which this ui-view "tag" was created
210+ return parse ( '$cfg.viewDecl.$context' ) ( inherited ) ;
211+ }
205212 } ;
206213
207214 trace . traceUiViewEvent ( "Linking" , activeUIView ) ;
@@ -298,8 +305,12 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
298305 return directive ;
299306}
300307
301- $ViewDirectiveFill . $inject = [ '$compile' , '$controller' , '$interpolate' , '$injector' , '$q' ] ;
302- function $ViewDirectiveFill ( $compile , $controller , $interpolate , $injector , $q ) {
308+ $ViewDirectiveFill . $inject = [ '$compile' , '$controller' , '$transitions' , '$view' , '$timeout' ] ;
309+ function $ViewDirectiveFill ( $compile , $controller , $transitions , $view , $timeout ) {
310+ const getControllerAs = parse ( 'viewDecl.controllerAs' ) ;
311+ const getResolveAs = parse ( 'viewDecl.resolveAs' ) ;
312+ const getResolveContext = parse ( 'node.resolveContext' ) ;
313+
303314 return {
304315 restrict : 'ECA' ,
305316 priority : - 400 ,
@@ -310,15 +321,16 @@ function $ViewDirectiveFill ( $compile, $controller, $interpolate, $injec
310321 let data : UIViewData = $element . data ( '$uiView' ) ;
311322 if ( ! data ) return ;
312323
313- let cfg : Ng1ViewConfig = data . $cfg || < any > { } ;
324+ let cfg : Ng1ViewConfig = data . $cfg || < any > { viewDecl : { } } ;
314325 $element . html ( cfg . template || initial ) ;
315326 trace . traceUiViewFill ( data . $uiView , $element . html ( ) ) ;
316327
317328 let link = $compile ( $element . contents ( ) ) ;
318329 let controller = cfg . controller ;
319- let controllerAs = cfg . controllerAs ;
320- let resolveAs = cfg . resolveAs ;
321- let locals = map ( cfg . node && cfg . node . resolves || { } , r => r . data ) ;
330+ let controllerAs : string = getControllerAs ( cfg ) ;
331+ let resolveAs : string = getResolveAs ( cfg ) ;
332+ let resolveCtx : ResolveContext = getResolveContext ( cfg ) ;
333+ let locals = resolveCtx && map ( resolveCtx . getResolvables ( ) , r => r . data ) ;
322334
323335 scope [ resolveAs ] = locals ;
324336
0 commit comments