1
1
/** @module view */ /** for typedoc */
2
+ "use strict" ;
2
3
import { extend , map } from "../common/common" ;
3
4
import { isDefined , isFunction } from "../common/predicates" ;
4
5
import { trace } from "../common/trace" ;
5
6
import { ActiveUIView } from "../view/interface" ;
6
7
import { 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" ;
7
12
8
13
export type UIViewData = {
9
14
$cfg : Ng1ViewConfig ;
@@ -174,7 +179,7 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
174
179
}
175
180
176
181
let rootData = {
177
- $cfg : { context : $view . rootContext ( ) } ,
182
+ $cfg : { viewDecl : { $ context : $view . rootContext ( ) } } ,
178
183
$uiView : { }
179
184
} ;
180
185
@@ -201,7 +206,9 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
201
206
fqn : inherited . $uiView . fqn ? inherited . $uiView . fqn + "." + name : name , // fully qualified name, describes location in DOM
202
207
config : null , // The ViewConfig loaded (from a state.views definition)
203
208
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
+ }
205
212
} ;
206
213
207
214
trace . traceUiViewEvent ( "Linking" , activeUIView ) ;
@@ -298,8 +305,12 @@ function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate,
298
305
return directive ;
299
306
}
300
307
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
+
303
314
return {
304
315
restrict : 'ECA' ,
305
316
priority : - 400 ,
@@ -310,15 +321,16 @@ function $ViewDirectiveFill ( $compile, $controller, $interpolate, $injec
310
321
let data : UIViewData = $element . data ( '$uiView' ) ;
311
322
if ( ! data ) return ;
312
323
313
- let cfg : Ng1ViewConfig = data . $cfg || < any > { } ;
324
+ let cfg : Ng1ViewConfig = data . $cfg || < any > { viewDecl : { } } ;
314
325
$element . html ( cfg . template || initial ) ;
315
326
trace . traceUiViewFill ( data . $uiView , $element . html ( ) ) ;
316
327
317
328
let link = $compile ( $element . contents ( ) ) ;
318
329
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 ) ;
322
334
323
335
scope [ resolveAs ] = locals ;
324
336
0 commit comments