Why doesn't Angular 2 allow me to create a set of child views inside a div block using * ngFor?
Happening:
import {Component, Input} from '@angular/core'; import {ChoiceComponent} from './choice.component'; import {Question} from './model/Question'; @Component({ selector: 'question', template: ` <div class="panel"> {{question.text}} <choice *ngFor="let choice of question.choices" [choice]="choice"> </div> `, directives: [ChoiceComponent] }) export class QuestionComponent { @Input() question: Question;
Causes
EXCEPTION: Template parse errors: Unexpected closing tag "div" (" <div class="panel"> <choice *ngFor="let choice of question.choices" [choice]="choice"> [ERROR ->]</div> "): QuestionComponent@3 :4
However, the following works are fine, but I want to have the question and selection buttons inside the same panel.
<div class="panel"> {{question.text}} </div> <choice *ngFor="let choice of question.choices" [choice]="choice">
source share