I want to set value in array like this:
this.form.controls[name].setValue(\'name\')
but I am working w
Here is what I have done to set value manually in formArray's specific form control and worked for me. I have formArray named as bundleDetails.
this.formBuilderObj['bundleDetails'] =
this.formBuilder.array([this.createBundleItem()]);
createBundleItem(): FormGroup {
return this.formBuilder.group({
bsku: ['', Validators.required],
bqty: ['', Validators.required],
bprice: ['', Validators.required]
});
}
Method to set bsku control's value (where index is [formGroupName]="i" passed from html file).
setSku(sku: string, index: number) {
const faControl =
(this.pmForm.controls['bundleDetails']).at(index);
faControl['controls'].bsku.setValue(sku);
}
Hope this helps. Happy coding.