Cannot find control with name: formControlName in angular reactive form

前端 未结 6 1023
無奈伤痛
無奈伤痛 2020-12-25 11:47

I found this problem in many questions in stackoverflow but no luck. Please help me for figuring out what I am doing wrong.

In component :

6条回答
  •  离开以前
    2020-12-25 12:21

    I tried to generate a form dynamically because the amount of questions depend on an object and for me the error was fixed when I added ngDefaultControl to my mat-form-field.

        
    {{question.questionContent}}

    In sendFeedback() I get the value from my dynamic form by selecting the formgroup's value as such

      sendFeedbackAsAgent():void {
        if (this.questionsForm.valid) {
          console.log(this.questionsForm.value)
        }
      }
    

提交回复
热议问题