【发布时间】:2020-08-27 00:04:54
【问题描述】:
有人可以帮我如何在 ngFor 中创建动态模板引用变量,下面是我的代码
在这里,我想根据我的 ngFor 动态使用 [matAutocomplete]="auto" 和 mat-autocomplete #auto="matAutocomplete"
<div class="col" *ngFor="let item of formItems;">
<mat-form-field>
<input type="text" placeholder="{{item.label}}" aria-label="Number" matInput
formControlName={{item.type}} [matAutocomplete]="auto" id="item.type">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)='updateData(item.type)'>
<mat-option *ngFor="let option of item.filterdData | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
</div>
【问题讨论】:
标签: angular angular-material ngfor