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()
ExtendedFormControl
s will be created for model properties decorated with theAttribute(options: PropertyOptions)
decorator.- See PropertyOptions for more information about the decorator options
BelongsTo(options: PropertyOptions)
ExtendedFormControl
s 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
ExtendedFormArray
will 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
isChanged
behavior for that attribute - arguments:
initialValue
- the raw value of the array at the creation of theExtendedFormArray
/ExtendedFormControl
controlcurrentValue
- the current raw value of the arrayformControl
- the instance of the decoratedExtendedFormControl
orExtendedFormArray
You can override default control types in FormObject.