Decorators
ngx-form-object exposes three decorators: Attribute(), BelongsTo(), and HasMany().
You can use one of these decorators to specify what kind of form controls should FormObjectbuilder create for different model properties.
Attribute()
ExtendedFormControls will be created for model properties decorated with theAttribute(options: PropertyOptions)decorator.- See PropertyOptions for more information about the decorator options
BelongsTo(options: PropertyOptions)
ExtendedFormControls will be created for model properties decorated with theBelongsTo(options: PropertyOptions)decorator.- See PropertyOptions for more information about the decorator options
HasMany(options: PropertyOptions)
- Empty
ExtendedFormArraywill be created for model properties decorated with theHasMany(options: PropertyOptions)decorator. - See PropertyOptions for more information about the decorator options
PropertyOptions
Each of the decorators accepts a PropertyOptions optional argument.
PropertyOptions:
isChanged(initialValue: any, currentValue: any, formControl: ExtendedFormControl | ExtendedFormArray): boolean- function can be defined in the options argument
- if defined, this function overrides the default
isChangedbehavior for that attribute - arguments:
initialValue- the raw value of the array at the creation of theExtendedFormArray/ExtendedFormControlcontrolcurrentValue- the current raw value of the arrayformControl- the instance of the decoratedExtendedFormControlorExtendedFormArray
You can override default control types in FormObject.