[英]angular material mat-autocomplete opens panel
我有自動完成字段的模式。 我將Angular 5與角度材料2一起使用。加載模態時,第一個字段的面板始終處於打開狀態...
如何避免這種情況?
我試圖在另一個字段上使用自動對焦屬性,但是它不起作用...
<form name="indexation">
<br>
<div class="row">
<div class="col-md-12">
<mat-form-field class="index-full-width">
<input
matInput
type="text"
[(ngModel)]="patientChoice"
placeholder="Patient"
aria-label="Patient"
[matAutocomplete]="autoPatient"
[formControl]="myControl">
<mat-autocomplete (optionSelected)="selectPat()" #autoPatient="matAutocomplete" [displayWith]="displayFnPat">
<mat-option *ngFor="let patient of filteredPatients | async" [value]="patient">
<span>{{ patient.lastName }}</span>
<small>{{patient.firstName}}</small> |
<span>né(e) le {{ patient.dateNaissance }}</span> |
<small>IPP: {{patient.ipp}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
</div>
<br>
這個問題是否來自物質?
當有待顯示的選項並且該字段具有焦點時,結果面板將自動打開。 默認情況下,對話框會將焦點設置在第一個可聚焦元素上,因此我認為這就是為什么在對話框加載時自動完成功能會打開的原因。 為避免這種情況,請在啟動對話框時使用MatDialogConfig選項autoFocus: false
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.