我们将ngx-chips用于自动完成文本框,在这里我们从远程源获取数据。如果我们复制粘贴项目,然后按Tab键,则需要选择单个项目。但这是行不通的。
我们将不胜感激任何帮助。
我们的代码如下
<tag-input formControlName="Tag"
placeholder = "select"
secondaryPlaceholder = "select"
[validators]="Validator"
[onlyFromAutocomplete]="true"
[onTextChangeDebounce] = "1000"
(keyup)="onSearchType($event.target.value)"
class="tag-input-class tag-inp"
>
<tag-input-dropdown
[autocompleteItems]="List"
[dynamicUpdate]="true"
[appendToBody]="true"
[showDropdownIfEmpty]="false"
[keepOpen]="false"
[zIndex] = "1000000"
[displayBy]="'property'"
[identifyBy] ="'property'"
>
</tag-input-dropdown>
</tag-input>
答案 0 :(得分:0)
您可以使用separatorKeyCodes
属性来实现此目的,
<tag-input formControlName="Tag"
placeholder = "select"
secondaryPlaceholder = "select"
[validators]="Validator"
[onlyFromAutocomplete]="true"
[onTextChangeDebounce] = "1000"
[separatorKeyCodes]="'TAB'" or "TAB" or "[TAB]" //please try this
(keyup)="onSearchType($event.target.value)"
class="tag-input-class tag-inp">
<tag-input-dropdown
[autocompleteItems]="List"
[dynamicUpdate]="true"
[appendToBody]="true"
[showDropdownIfEmpty]="false"
[keepOpen]="false"
[zIndex] = "1000000"
[displayBy]="'property'"
[identifyBy] ="'property'">
</tag-input-dropdown>
</tag-input>