I have a JSON response coming back from the server that is an assessment object with an array of questions. I need to path the values to my reactive form. This patch value function is working when there is only 1 question:
this.caseAssessmentForm.patchValue({
ID: assessment.templateID,
name: assessment.name,
type: assessment.typeName,
status: "Not Started",
description: assessment.description,
questions: {
questionScore: '',
questionAnswer: '',
questionGoal: assessment.templateQuestions[0].goal,
questionName: assessment.templateQuestions[0].name
}
});
The problem is that once there are multiple questions returning, I can't patch the value as an array. I've tried using questions: this.FormBuiler.array([]), but I still can't figure out how to dynamically patch the values. Does anyone have any ideas?
questionsis an object , not an array , can u please give me an example of the JSON coming from the server when the assessment contains more than one questiondescription: "Six" name: "Template Six" status: Not Started" templateID: 3 templateQuestions: Array(3) 0{questionID: 6, name: "Check your favorite one", goal: "Any Goal", isAddToOverview: false, isDefaultToLastResponse: null, …} 1{questionID: 3, name: "Question 3", goal: "Any Goal", isAddToOverview: false, isDefaultToLastResponse: null, …} 2 {questionID: 1, name: "Question 1", goal: "Any Goal", isAddToOverview: false, isDefaultToLastResponse: null, …}