Skip to content

Commit e94102a

Browse files
committed
Updated readme for condition and gulped
1 parent a82067e commit e94102a

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

dist/schema-form.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ angular.module('schemaForm').provider('schemaFormDecorators',
168168

169169
var createDirective = function(name) {
170170
$compileProvider.directive(name,
171-
['$parse', '$compile', '$http', '$templateCache', '$interpolate', '$q', 'sfErrorMessage',
172-
function($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage) {
171+
['$parse', '$compile', '$http', '$templateCache', '$interpolate', '$q', 'sfErrorMessage', 'sfPath',
172+
function($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage, sfPath) {
173173

174174
return {
175175
restrict: 'AE',
@@ -341,18 +341,23 @@ angular.module('schemaForm').provider('schemaFormDecorators',
341341
// Do we have a condition? Then we slap on an ng-if on all children,
342342
// but be nice to existing ng-if.
343343
if (form.condition) {
344+
345+
var evalExpr = 'evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex})';
346+
if (form.key) {
347+
evalExpr = 'evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex, "modelValue": model' + sfPath.stringify(form.key) + '})';
348+
}
349+
344350
angular.forEach(element.children(), function(child) {
345351
var ngIf = child.getAttribute('ng-if');
346352
child.setAttribute(
347353
'ng-if',
348354
ngIf ?
349355
'(' + ngIf +
350-
') || (evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex }))'
351-
: 'evalExpr(form.condition,{ model: model, "arrayIndex": arrayIndex })'
356+
') || (' + evalExpr +')'
357+
: evalExpr
352358
);
353359
});
354360
}
355-
356361
$compile(element.contents())(scope);
357362
});
358363

0 commit comments

Comments
 (0)