Is it possible to create independent child Components from ngFor iteration in Angular 2?
I'm making a Quiz application with a structure, where one Quiz
component have multiple Categories
, and one Category have multiple Questions
.
Angular will generate a form from Quiz retrieved from REST api, where user can navigate back and forth between different categories of questions and finally save partial or submit complete form.
I sketched the following pseudo-structure for application template:
<html>
<form>
<category>
<question *ngFor="let question of questions" />
<category>
<navigate/>
</form>
</html>
Quiz component
has a list of categories and a reference to an active category. Category component
has input binding to reflect the active category of Quiz. Category
has list of Questions, which I want to encapsulate in distinct Component. Thus I iterate through the list of questions and create question tag.
Now the problem is, how I populate the Question component
for each tag according the question object creating that tag? Is this possible, or should I merge the question template with Category?