gpt4 book ai didi

对话框打开面板上的 Angular Material 垫自动完成

转载 作者:行者123 更新时间:2023-12-02 16:56:07 28 4
gpt4 key购买 nike

我有带有自动完成字段的模态。我使用 Angular 5 和 Angular Material 2。当模态加载时,第一个字段的面板始终打开...

enter image description here

如何避免这种情况?

我尝试在另一个字段上使用自动对焦属性,但它不起作用...

<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>

这个问题是否来自 Material ?

最佳答案

当有要显示的选项并且该字段具有焦点时,结果面板将自动打开。默认情况下,对话框会将焦点设置在第一个可聚焦元素上,因此我认为这就是在加载对话框时打开自动完成功能的原因。为了避免这种情况,请在启动对话框时使用 MatDialogConfig 选项 autoFocus: false

关于对话框打开面板上的 Angular Material 垫自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50099529/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com