angular2-forms

FormGroup inside FormArray in Angular 2 Reactive Forms

前提是你 提交于 2020-12-05 05:46:41
问题 I failed to get an Angular 2 reactive form to work which has a FormGroup nested in a FormArray . Can somebody show me what is wrong in my setup. Unrelated parts of the code has been omitted for the brevity. Following is my component orderForm: FormGroup = this.fb.group({ id: [''], store: ['', Validators.required], //The part related to the error order_lines: this.fb.array([ this.fb.group({ id: [''], order_id: [], product_id: [], description: ['', Validators.required], unit_price: ['',

FormGroup inside FormArray in Angular 2 Reactive Forms

亡梦爱人 提交于 2020-12-05 05:46:11
问题 I failed to get an Angular 2 reactive form to work which has a FormGroup nested in a FormArray . Can somebody show me what is wrong in my setup. Unrelated parts of the code has been omitted for the brevity. Following is my component orderForm: FormGroup = this.fb.group({ id: [''], store: ['', Validators.required], //The part related to the error order_lines: this.fb.array([ this.fb.group({ id: [''], order_id: [], product_id: [], description: ['', Validators.required], unit_price: ['',

Angular 2: Accessing data from FormArray

夙愿已清 提交于 2020-11-30 03:56:43
问题 I have prepared a from using ReactiveForms provided by angular2/forms. This form has a form array products: this.checkoutFormGroup = this.fb.group({ selectedNominee: ['', Validators.required], selectedBank: ['', Validators.required], products: productFormGroupArray }); productFormGroupArray is a array of FormGroup Objects.I fetched the controls i.e. FormArray object using this: this.checkoutFormGroup.get('products') I am trying to get the element in the products array at index i . How can