11
我已经准备好了使用angular2/forms提供的ReactiveForms。这种形式的一种形式阵列产品:Angular 2:从FormArray访问数据
this.checkoutFormGroup = this.fb.group({
selectedNominee: ['', Validators.required],
selectedBank: ['', Validators.required],
products: productFormGroupArray
});
productFormGroupArray是FormGroup Objects.I的阵列获取的控件使用该IE FormArray对象:
this.checkoutFormGroup.get('products')
我想获得的产品元素阵列在索引i
。如何在不循环数组的情况下做到这一点?
编辑:
我在可用的(索引)方法尝试:
this.checkoutFormGroup.get('products').at(index)
但这产生误差为:
Property 'at' does not exist on type 'AbstractControl'.
编辑2: checkoutData和资金从服务器接收。
this.checkoutData.products.forEach(product => {
this.fundFormGroupArray.push(this.fb.group({
investmentAmount: [this.fund.minInvestment, Validators.required],
selectedSubOption: ['', Validators.required],
}))
});
请分享它告诉你如何定义的代码'productFormGroupArray' – ranakrunal9
@ ranakrunal9编辑的题 –