【发布时间】:2019-03-18 23:28:59
【问题描述】:
我现在正在尝试更改 mat-autocomplete 中的项目数一段时间,但没有成功。我正在使用 material.angular.io
这是我的代码
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-add-and-search',
templateUrl: './add-and-search.component.html',
styleUrls: ['./add-and-search.component.css']
})
export class AddAndSearchComponent implements OnInit {
items: string[] = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5'];
constructor() { }
ngOnInit() {
}
}
<mat-form-field appearance="standard">
<mat-label>Search...</mat-label>
<input matInput placeholder="Search..." [matAutocomplete]="auto">
<mat-icon matSuffix>search</mat-icon>
</mat-form-field>
<mat-autocomplete #auto="matAutocomplete">
<mat-optgroup label="Items">
<mat-option *ngFor="let item of items" [value]="item">{{item}}</mat-option>
<mat-option><mat-icon>add</mat-icon>Add</mat-option>
</mat-optgroup>
</mat-autocomplete>
从文档中我了解到自动完成面板的高度恒定为 256 像素 (https://material.angular.io/components/autocomplete/api#AUTOCOMPLETE_PANEL_HEIGHT)。
我的问题是:如何更改自动完成面板以显示更多项目。比方说 10。如果没有打算这样做的方法,有人可以给我一个关于设置高度的 CSS 技巧的提示,例如改为 512px 而不是默认的 256px?
非常感谢!
【问题讨论】:
标签: html css angular angular-material