patch Value in a nested form control using angular2

前端 未结 8 1412
日久生厌
日久生厌 2020-12-19 09:34

I need to set a value in a nested control in a FormBuiler and the model is the following:

this.addAccForm = this.fb.group({
      accid: [\'\', Validators.re         


        
8条回答
  •  清歌不尽
    2020-12-19 10:06

    Here is the code for working for me.

    I am using Angular Version "^6.0.0"

    var formArray = this.addAccForm.get("cyc") as FormArray;
    formArray.at(0)["controls"]["cycid"].patchValue("Value that you want to pass");
    

提交回复
热议问题