所以我有这个标记,它可以正常工作,除了当ngIf从dom中删除选项时,我需要立即触发change事件。
<select
class="form-control ml-1"
(change)="selectOption($event.target.value,item.id)"
>
<ng-container *ngFor="let opt of selectOptions">
<option
[value]="opt.id"
[selected]="opt.id == getDataType(item.id)"
*ngIf="
(opt.pie == true &&
layoutService.getcomponentRef(item.id) == 'pie') ||
(opt.line == true &&
layoutService.getcomponentRef(item.id) == 'line') ||
(opt.bar == true &&
layoutService.getcomponentRef(item.id) == 'bar')
"
>{{ opt.name }}</option
>
</ng-container>
</select>