This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-17
lines changed Expand file tree Collapse file tree 1 file changed +18
-17
lines changed Original file line number Diff line number Diff line change 79
79
</file>
80
80
</example>
81
81
*/
82
- var ngIfDirective = [ '$animate' , function ( $animate ) {
82
+ var ngIfDirective = [ '$animate' , '$parse' , function ( $animate , $parse ) {
83
83
return {
84
84
transclude : 'element' ,
85
85
priority : 600 ,
@@ -89,10 +89,12 @@ var ngIfDirective = ['$animate', function($animate) {
89
89
compile : function ( element , attr , transclude ) {
90
90
return function ( $scope , $element , $attr ) {
91
91
var block , childScope ;
92
- $scope . $watch ( $attr . ngIf , function ngIfWatchAction ( value ) {
93
-
94
- if ( toBoolean ( value ) ) {
95
- if ( ! childScope ) {
92
+ $scope . $watch (
93
+ function ngIfWatchExpression ( ) {
94
+ return toBoolean ( $parse ( $attr . ngIf ) ( $scope ) ) ;
95
+ } ,
96
+ function ngIfWatchAction ( value ) {
97
+ if ( value ) {
96
98
childScope = $scope . $new ( ) ;
97
99
transclude ( childScope , function ( clone ) {
98
100
block = {
@@ -101,20 +103,19 @@ var ngIfDirective = ['$animate', function($animate) {
101
103
} ;
102
104
$animate . enter ( clone , $element . parent ( ) , $element ) ;
103
105
} ) ;
104
- }
105
- } else {
106
-
107
- if ( childScope ) {
108
- childScope . $destroy ( ) ;
109
- childScope = null ;
110
- }
111
-
112
- if ( block ) {
113
- $animate . leave ( getBlockElements ( block ) ) ;
114
- block = null ;
106
+ } else {
107
+ if ( childScope ) {
108
+ childScope . $destroy ( ) ;
109
+ childScope = null ;
110
+ }
111
+
112
+ if ( block ) {
113
+ $animate . leave ( getBlockElements ( block ) ) ;
114
+ block = null ;
115
+ }
115
116
}
116
117
}
117
- } ) ;
118
+ ) ;
118
119
} ;
119
120
}
120
121
} ;
You can’t perform that action at this time.
0 commit comments