How to set value to form control in Reactive Forms in Angular

前端 未结 6 1381
广开言路
广开言路 2020-11-28 08:15

Hi Everyone I\'m new to angular. Actually, I\'m trying to subscribe data from a service and that data, I\'m passing to form control of mine from (example, it\'s like an edit

6条回答
  •  我在风中等你
    2020-11-28 08:36

    Use patchValue() method which helps to update even subset of controls.

    setValue(){
      this.editqueForm.patchValue({user: this.question.user, questioning: this.question.questioning})
    }
    


    From Angular docs setValue() method:

    Error When strict checks fail, such as setting the value of a control that doesn't exist or if you excluding the value of a control.

    In your case, object missing options and questionType control value so setValue() will fail to update.

提交回复
热议问题