@@ -31,8 +31,8 @@ angular.module('schemaForm').provider('schemaFormDecorators',
3131
3232 var createDirective = function ( name ) {
3333 $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 ) {
3636
3737 return {
3838 restrict : 'AE' ,
@@ -204,18 +204,23 @@ angular.module('schemaForm').provider('schemaFormDecorators',
204204 // Do we have a condition? Then we slap on an ng-if on all children,
205205 // but be nice to existing ng-if.
206206 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+
207213 angular . forEach ( element . children ( ) , function ( child ) {
208214 var ngIf = child . getAttribute ( 'ng-if' ) ;
209215 child . setAttribute (
210216 'ng-if' ,
211217 ngIf ?
212218 '(' + ngIf +
213- ') || (evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex }) )'
214- : ' evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex })'
219+ ') || (' + evalExpr + ' )'
220+ : evalExpr
215221 ) ;
216222 } ) ;
217223 }
218-
219224 $compile ( element . contents ( ) ) ( scope ) ;
220225 } ) ;
221226
0 commit comments