如何使用 Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS 注入令牌 [英] How to use Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS injection token

查看:18
本文介绍了如何使用 Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS 注入令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 MAT_AUTOCOMPLETE_DEFAULT_OPTIONS 注入令牌或 const AUTOCOMPLETE_OPTION_HEIGHT 自定义 mat-autocomplete 的方法是什么.这些常量以及其他常量在公共 API 此处 中公开,但没有关于如何使用的文档他们

What is the way to use the MAT_AUTOCOMPLETE_DEFAULT_OPTIONS injection token, or the const AUTOCOMPLETE_OPTION_HEIGHT to customize mat-autocomplete. These constants, among others are exposed in the public API here but no documentation on how to use them

推荐答案

MAT_AUTOCOMPLETE_DEFAULT_OPTIONS 添加到模块的 providers 数组中,如下所示:

Add MAT_AUTOCOMPLETE_DEFAULT_OPTIONS to your module's providers array like this:

providers: [
  // ...
  {provide: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, useValue: {autoActiveFirstOption: false}}
]

至于其他常量,我不确定您是否可以调整它们.您可能需要使用 CSS 样式,例如参见 this issue用于调整面板高度.

As for the other constants, I'm not sure you can adjust them. You'll probably have to play around with the CSS styles, see for instance this issue for adjusting the panel height.

这篇关于如何使用 Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS 注入令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆