Form Control:
Smallest unit, represents input, radio, select, whatever form HTML element it is bind with.
- FormControl {
- asyncValidator: null
- errors: null
- pristine: true
- status: "VALID"
- statusChanges: EventEmitter {_isScalar: false, observers: Array(0), closed: false, isStopped: false, hasError: false, …}
- touched: true
- validator: null
- value: ""
- valueChanges: EventEmitter {_isScalar: false, observers: Array(1), closed: false, isStopped: false, hasError: false, …}
- _onChange: [ƒ]
- _onCollectionChange: () => { }
- _onDisabledChange: [ƒ]
- _parent: FormGroup {validator: null, asyncValidator: null, pristine: true, touched: true, _onCollectionChange: ƒ, …}
- _pendingTouched: true
- _pendingValue: ""
- dirty: (...)
- disabled: (...)
- enabled: (...)
- invalid: (...)
- parent: (...)
- pending: (...)
- root: (...)
- untouched: (...)
- updateOn: (...)
- valid: (...)
- __proto__: AbstractControl
- }
- Form Group:
- Object, and in controls it contains object of formcontrols or formArray.
- {
- asyncValidator: null
- controls: {userLst: FormArray, test: FormControl}
- errors: null
- pristine: true
- status: "VALID"
- statusChanges: EventEmitter {_isScalar: false, observers: Array(0), closed: false, isStopped: false, hasError: false, …}
- touched: false
- validator: null
- value: {userLst: Array(15)}
- valueChanges: EventEmitter {_isScalar: false, observers: Array(0), closed: false, isStopped: false, hasError: false, …}
- _onCollectionChange: () => this._updateDomValue()
- _onDisabledChange: []
- dirty: (...)
- disabled: (...)
- enabled: (...)
- invalid: (...)
- parent: (...)
- pending: (...)
- root: (...)
- untouched: (...)
- updateOn: (...)
- valid: (...)
- __proto__: AbstractControl
- }
- Form Array, similar to form control, but in controls, it contains an array of form control instead of object:
- {
- asyncValidator: null
- controls: (15) [FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl, FormControl]
- errors: null
- pristine: true
- status: "VALID"
- statusChanges: EventEmitter {_isScalar: false, observers: Array(0), closed: false, isStopped: false, hasError: false, …}
- touched: false
- validator: null
- value: (15) [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]
- valueChanges: EventEmitter {_isScalar: false, observers: Array(0), closed: false, isStopped: false, hasError: false, …}
- _onCollectionChange: () => { }
- _onDisabledChange: []
- _parent: FormGroup {validator: null, asyncValidator: null, pristine: true, touched: false, _onCollectionChange: ƒ, …}
- dirty: (...)
- disabled: (...)
- enabled: (...)
- invalid: (...)
- length: (...)
- parent: (...)
- pending: (...)
- root: (...)
- untouched: (...)
- updateOn: (...)
- valid: (...)
- __proto__: AbstractContro; }
- Details guide:
- https://stackoverflow.com/questions/41288928/when-to-use-formgroup-vs-formarray#:~:text=4%20Answers&text=FormArray%20is%20a%20variant%20of,the%20group%2C%20like%20dynamic%20forms.
- https://medium.com/aviabird/complete-angular2-guide-reactive-forms-in-depth-part-1-21a8e2428904
- https://ashish173.github.io/ng2-forms/trip/create
- https://github.com/ashish173/ng2-forms/blob/master/src/app/components/trip-edit/trip-edit.component.ts
- https://github.com/ashish173/ng2-forms/blob/master/src/app/components/trip-edit/trip-edit.component.html
No comments:
Post a Comment