You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `sfField` builder adds the `sf-field="..."` directive to *the first child element* in the template,
301
+
The `sfField` builder adds the `sf-field="..."` directive to *the first child element* in the template,
228
302
giving it a correct value. The value is an id number that identifies that specific form object.
229
303
230
-
The `sf-field` directive exports the form definition object as `form` on scope and as a lot of useful functions.
304
+
The `sf-field` directive exports the form definition object as `form` on scope and as a lot of useful functions.
231
305
232
-
As a rule of thumb you always want this builder.
306
+
As a rule of thumb you always want this builder.
233
307
234
308
### builders.condition
235
-
The `condition` builder checks the form definition for the option `condition`. If it's present it adds a
309
+
The `condition` builder checks the form definition for the option `condition`. If it's present it adds a
236
310
`ng-if` to all top level elements in the template.
237
311
238
312
You usually want this as well.
239
313
240
-
### builder.ngModel
314
+
### builder.ngModel
241
315
The `ngModel` builder is maybe the most important builder. It makes sure you get a proper binding to
242
-
your model value.
316
+
your model value.
243
317
244
-
The `ngModel` builder queries the DOM of the template for all elements that have the attribute `sf-field-model`. Your template may have several of them. `sf-field-model` is *not* a directive,
318
+
The `ngModel` builder queries the DOM of the template for all elements that have the attribute `sf-field-model`. Your template may have several of them. `sf-field-model` is *not* a directive,
245
319
but depending on it's value the `ngModel` builder will take three different actions.
246
320
247
-
248
-
#### sf-field-model
249
-
Just `sf-field-model` or `sf-field-model=""` tells the builder to add a `ng-model` directive to this element.
321
+
#### sf-field-model
322
+
Just `sf-field-model` or `sf-field-model=""` tells the builder to add a `ng-model` directive to this element.
250
323
This is a common use case.
251
324
252
-
Ex:
325
+
Ex:
253
326
DOM before `ngModel` builder:
254
327
```html
255
328
<div>
@@ -263,11 +336,11 @@ DOM after `ngModel` builder:
263
336
</div>
264
337
```
265
338
266
-
#### sf-field-model="<attributename>"
267
-
Given a value the `ngModel` builder will treat that value as a *attribute name* and instead of slapping
339
+
#### sf-field-model="attribute name"
340
+
Given a value the `ngModel` builder will treat that value as a *attribute name* and instead of slapping
268
341
on a `ng-model` set the specified attributes value. It sets it to the same value as the `ng-model` would have gotten.
269
342
270
-
Ex:
343
+
Ex:
271
344
DOM before `ngModel` builder:
272
345
```html
273
346
<divsf-field-model="my-directive">
@@ -283,13 +356,13 @@ DOM after `ngModel` builder:
283
356
284
357
#### sf-field-model="replaceAll"
285
358
With the special value *replaceAll* the `ngModel` builder will instead loop over every attribute on the
286
-
element and do a string replacement of `"$$value$$"` with the proper model value.
359
+
element and do a string replacement of `"$$value$$"` with the proper model value.
287
360
288
-
Ex:
361
+
Ex:
289
362
DOM before `ngModel` builder:
290
363
```html
291
364
<div>
292
-
<inputsf-field-model="replaceAll"
365
+
<inputsf-field-model="replaceAll"
293
366
ng-model="$$value$$"
294
367
ng-class="{'large': $$value$$.length > 10}"
295
368
type="text">
@@ -298,7 +371,7 @@ DOM before `ngModel` builder:
298
371
DOM after `ngModel` builder:
299
372
```html
300
373
<div>
301
-
<inputsf-field-model="replaceAll"
374
+
<inputsf-field-model="replaceAll"
302
375
ng-model="model['name']"
303
376
ng-class="{'large': model[name].length > 10}"
304
377
type="text">
@@ -307,7 +380,7 @@ DOM after `ngModel` builder:
307
380
308
381
### builders.ngModelOptions
309
382
If the form definition has a `ngModelOptions` option specified this builder will slap on a `ng-model-options`
310
-
attribute to *the first child element* in the template.
383
+
attribute to *the first child element* in the template.
311
384
312
385
313
386
### builder.simpleTransclusion
@@ -317,4 +390,31 @@ is simple because it only appends children to the first child element and only c
317
390
318
391
Useful directives
319
392
-----------------
320
-
TODO: more in depth about schema-validate, sf-messages and sf-field
393
+
394
+
### sf-field
395
+
sfField is the directive that adds scope to the template
396
+
397
+
#### What's on the scope?
398
+
You have several helper functions and values on the scope, most important of this `form`. The
399
+
`form` variable contains the merged form definition for that field, i.e. your supplied form object +
400
+
the defaults from the schema (it also has its part of the schema under *form.schema*).
401
+
This is how you define and use new form field options, whatever is set on the form object is
0 commit comments