如何使用Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS注射令牌 [英] How to use Angular Material MAT_AUTOCOMPLETE_DEFAULT_OPTIONS injection token
问题描述
使用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屋!