@@ -31,8 +31,8 @@ angular.module('schemaForm').provider('schemaFormDecorators',
31
31
32
32
var createDirective = function ( name ) {
33
33
$compileProvider . directive ( name ,
34
- [ '$parse' , '$compile' , '$http' , '$templateCache' , '$interpolate' , '$q' , 'sfErrorMessage' ,
35
- function ( $parse , $compile , $http , $templateCache , $interpolate , $q , sfErrorMessage ) {
34
+ [ '$parse' , '$compile' , '$http' , '$templateCache' , '$interpolate' , '$q' , 'sfErrorMessage' , 'sfPath' ,
35
+ function ( $parse , $compile , $http , $templateCache , $interpolate , $q , sfErrorMessage , sfPath ) {
36
36
37
37
return {
38
38
restrict : 'AE' ,
@@ -204,18 +204,23 @@ angular.module('schemaForm').provider('schemaFormDecorators',
204
204
// Do we have a condition? Then we slap on an ng-if on all children,
205
205
// but be nice to existing ng-if.
206
206
if ( form . condition ) {
207
+
208
+ var evalExpr = 'evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex})' ;
209
+ if ( form . key ) {
210
+ evalExpr = 'evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex, "modelValue": model' + sfPath . stringify ( form . key ) + '})' ;
211
+ }
212
+
207
213
angular . forEach ( element . children ( ) , function ( child ) {
208
214
var ngIf = child . getAttribute ( 'ng-if' ) ;
209
215
child . setAttribute (
210
216
'ng-if' ,
211
217
ngIf ?
212
218
'(' + ngIf +
213
- ') || (evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex, "modelValue": model[" ' + form . key . join ( '"]["' ) + '"] }) )'
214
- : ' evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex, "modelValue": model["' + form . key . join ( '"]["' ) + '"] })'
219
+ ') || (' + evalExpr + ' )'
220
+ : evalExpr
215
221
) ;
216
222
} ) ;
217
223
}
218
-
219
224
$compile ( element . contents ( ) ) ( scope ) ;
220
225
} ) ;
221
226
0 commit comments