Is there a way to reuse a component selector with the following structure?
@Component({
selector: 'expression-builder',
template: `
<div class="container">
<expression *ngFor="#expression of expressions" [prototypes]="prototypes" [expression]="expression" [expressions]="expressions"></expression>
<a class="btn btn-primary" (click)="addExpression()"><i class="glyphicon glyphicon-plus"></i></a>
</div>
`,
})
When I try to use this in another component, it doesn't display anything:
@Component({
selector: 'expression',
template: `
<div class="row">
<!-- First Select -->
<div class="col-xs-3">
<select class="form-control" [(ngModel)]="selectedPrototypeSelector" (ngModelChange)="onPrototypeChange()">
<option *ngFor="#p of prototypes" [value]="p.selector">
{{ p.selectorName }}
</option>
</select>
</div>
<!-- Second Select -->
<div [ngClass]="{'col-xs-3': prototype?.valueType !== 'Set', 'col-xs-2': prototype?.valueType === 'Set'}" *ngIf="prototype">
<select class="form-control" [(ngModel)]="expression.constraint">
<option *ngFor="#constraint of prototype.constraints" [value]="constraint">
{{ constraint }}
</option>
</select>
</div>
<!-- Third Select -->
<div [ngClass]="{'col-xs-3': prototype?.valueType !== 'Set', 'col-xs-2': prototype?.valueType === 'Set'}">
<div>{{expression | json}}</div>
</div>
<div class="col-xs-1">
<a class="btn btn-danger pull-right" (click)="deleteExpression()"><i class="glyphicon glyphicon-remove"></i></a>
</div>
<!-- Expression Set selector -->
<div *ngIf="prototype?.valueType === 'Set'">
<expression-builder></expression-builder>
</div>
</div>
`,
directives: [ExpressionBuilderComponent]
})
However, I encounter the error message:
Unexpected directive value 'undefined'
I am looking for a solution to reuse the template specifically when valueType = Set
.