I want an opinion for the following scenario:
I have a survey with questions and answers:
questions: Question[];
answer: Answer[];
Where Question
is:
export class Question {
idQuestion: string;
question: string;
}
export class Answer {
idAnswer: string;
answer: string;
idQuestion: string;
type: string; // inputbox - select - etc
}
Currently I can render questions and answer separately:
<ul *ngFor="let question of questions;">
<li>
<a id="{{question.idQuestion}}">{{question.question}}</a>
</li>
</ul>
<ul *ngFor="let answer of answers;">
<li>
<a id="{{respuesta.idAnswer}}">{{answer.answer}}</a>
</li>
</ul>
But I want to render it in the way:
question1: answer;
question2: answer;
question3: select;
How can I face the problem? Is there any pattern in Angular2? I want to avoid the hardcoding of the html
from the ts
looping in the question and finding the answer.