@@ -9,9 +9,10 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
9
9
terminal : true ,
10
10
link : function ( scope , element , attr ) {
11
11
var viewScope , viewLocals ,
12
- name = attr [ directive . name ] || attr . name || '' ,
13
- onloadExp = attr . onload || '' ,
14
- animate = $animator && $animator ( scope , attr ) ;
12
+ name = attr [ directive . name ] || attr . name || '' ,
13
+ onloadExp = attr . onload || '' ,
14
+ doAnimate = isDefined ( $animator ) ,
15
+ animate = $animator ( scope , attr ) ;
15
16
16
17
// Find the details of the parent view directive (if any) and use it
17
18
// to derive our own qualified view name, then hang our own details
@@ -21,16 +22,16 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
21
22
var view = { name : name , state : null } ;
22
23
element . data ( '$uiView' , view ) ;
23
24
24
- scope . $on ( '$stateChangeSuccess' , updateView ) ;
25
- updateView ( ) ;
25
+ scope . $on ( '$stateChangeSuccess' , function ( ) { updateView ( doAnimate ) ; } ) ;
26
+ updateView ( false ) ;
26
27
27
- function updateView ( ) {
28
+ function updateView ( doAnimate ) {
28
29
var locals = $state . $current && $state . $current . locals [ name ] ;
29
30
if ( locals === viewLocals ) return ; // nothing to do
30
31
31
32
// Destroy previous view scope and remove content (if any)
32
33
if ( viewScope ) {
33
- if ( animate ) animate . leave ( element . contents ( ) , element ) ;
34
+ if ( doAnimate ) animate . leave ( element . contents ( ) , element ) ;
34
35
else element . html ( '' ) ;
35
36
36
37
viewScope . $destroy ( ) ;
@@ -42,7 +43,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
42
43
view . state = locals . $$state ;
43
44
44
45
var contents ;
45
- if ( animate ) {
46
+ if ( doAnimate ) {
46
47
contents = angular . element ( '<div></div>' ) . html ( locals . $template ) . contents ( ) ;
47
48
animate . enter ( contents , element ) ;
48
49
} else {
0 commit comments