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