patch Value in a nested form control using angular2

前端 未结 8 1386
日久生厌
日久生厌 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:30

    nested form patchvalue you need to use Array after object like this:

    this.userform.patchvalue({
     name: 'Ajay',
     approvers: [ {id:1} ]
    })
    

提交回复
热议问题