简体   繁体   English

Mat-autocomplete 下拉菜单用 enter 关闭选择

[英]Mat-autocomplete dropdown closes selecting with enter

Mat-autocomplete dropdown closes selecting with enter Mat-autocomplete 下拉菜单用 enter 关闭选择

im bulding a autocomplete chiplist.我正在构建一个自动完成的芯片列表。 and i want to be able to select multiple options before i close the list.在我关闭列表之前,我希望能够 select 多个选项。 it works perfect when using a mouse, but when i select with enter the list closes.它在使用鼠标时工作得很好,但是当我 select 输入列表时关闭。

does anybody have a solution for this problem?有人有解决这个问题的方法吗?

You should set [matChipInputSeparatorKeyCodes] for your matChipInput , is the list of key codes that will trigger a chipEnd event.您应该为您的matChipInput设置[matChipInputSeparatorKeyCodes] ,这是将触发 chipEnd 事件的键码列表。 Defaults to [ENTER] . Defaults to [ENTER]

html: html:
<input [matChipInputSeparatorKeyCodes]="separatorKeysCodes" ...>
ts: ts:
import { COMMA } from '@angular/cdk/keycodes';

separatorKeysCodes = [COMMA]; // for example

Full Example: https://material.angular.io/components/chips/examples#chips-input完整示例: https://material.angular.io/components/chips/examples#chips-input

Api: https://material.angular.io/components/chips/api#MatChipInput Api: https://material.angular.io/components/chips/api#MatChipInput

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM