在 Angular Material 1 中,可以通过单击按钮打开md-autocomplete
下拉列表(参见doc)。
mat-autocomplete
在 Angular Material 2 中,我认为(cf doc )没有这种可能性。这在某种程度上仍然可能吗?如何 ?我正在考虑使用input
隐藏和触发器openPanel
,但对于这样一个简单的用法来说似乎有点矫枉过正......
谢谢你的帮助
[编辑]
现在我的代码是这样的(我没有添加按钮,因为我不确定这是正确的方式)
<mat-form-field>
<input type="text" placeholder="Pronostique le futur vainqueur" aria-label="Vainqueur" matInput
[(ngModel)]="worldcupWinner" name="worldcupWinner" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let team of teams" [value]="team">
<img class="flag" [src]="team.flag_url" />
<span class="label">{{ team.name }}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>