【问题标题】:Material autocomplete panel issue材料自动完成面板问题
【发布时间】:2018-06-17 05:29:18
【问题描述】:

在我的 Angular 4 项目中,我遇到了 Material 自动完成的问题。 当我键入内容并且组件显示建议时,如果我滚动页面,我会看到建议面板与自动完成字段取消链接,就像您在图片中看到的那样。 但是在Material-Autocomplete我没有这个问题。

这是我的代码:

<mat-form-field>
        <input matInput placeholder="{{'customer.detail.labels.country'
          | translate }}" required [matAutocomplete]="tdAuto" name="country" #country="ngModel" [(ngModel)]="selected.country"
          (ngModelChange)="searchCountry($event)"> </mat-form-field>
            <mat-autocomplete #tdAuto="matAutocomplete" [displayWith]="displayFn">
            <mat-option (onSelectionChange)="setCountry(country)" *ngFor="let country of countries" [value]="country">
                <div class="row">
                  <img src="assets/img/flags24/{{country.alpha2Code | lowercase}}.png" />
                    <span>{{country.name}} ({{country.alpha2Code}})</span>
                </div>
            </mat-option>
        </mat-autocomplete>

【问题讨论】:

  • &lt;mat-form-field&gt; 应该围绕整个自动完成,而不仅仅是输入。不确定是否可以修复它
  • @Shadowlauch 不幸的是,它没有
  • @Alessandro 你能指定你使用的是哪个版本的角材料吗?
  • @The.Bear 是的,对不起,我正在使用 "@angular/material": "^2.0.0-beta.12" 和 angular 4.4.4
  • 这仍然发生在最新版本的角度/材料中,发生的事情是滚动事件永远不会被绑定到容器覆盖层 - 如果组件没有嵌套,它也不会发生布局

标签: angular angular-material


【解决方案1】:

在您的组件中使用 CdkScrollable。还将它添加到模块文件中的导入中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 2019-04-29
    • 1970-01-01
    相关资源
    最近更新 更多