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

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

问题描述

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

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样式,例如,参见此问题用于调整面板高度.

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天全站免登陆