Skip to content

Commit f7f0f6b

Browse files
committed
Added "model" to locals in condiftional
Makes it easy to write forms that doesn't need to now the particular name of the object.
1 parent 07a07da commit f7f0f6b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ A *conditional* is exactly the same as a *section*, i.e. a ```<div>``` with othe
224224
it, hence they need an ```items``` property. They also need a ```condition``` which is
225225
a string with an angular expression. If that expression evaluates as thruthy the *conditional*
226226
will be rendered into the DOM otherwise not. The expression is evaluated in the parent scope of
227-
the ```sf-schema``` directive (the same as onClick on buttons). This is useful for hiding/showing
227+
the ```sf-schema``` directive (the same as onClick on buttons) but with access to the current model
228+
under the name ```model```. This is useful for hiding/showing
228229
parts of a form depending on another form control.
229230
230231
ex. A checkbox that shows an input field for a code when checked
@@ -256,7 +257,7 @@ function FormCtrl($scope) {
256257
"eligible",
257258
{
258259
type: "conditional",
259-
condition: "person.eligible",
260+
condition: "person.eligible", //or "model.eligable"
260261
items: [
261262
"code"
262263
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div ng-if="!form.condition || evalExpr(form.condition)">
1+
<div ng-if="!form.condition || evalExpr(form.condition,{ model: model })">
22
<sf-decorator ng-repeat="item in form.items" form="item"></sf-decorator>
3-
</div>
3+
</div>

0 commit comments

Comments
 (0)