ngx-chips 最小文本长度

ngx-chips min text length

我正在使用 angular 形式的标签输入组件。

https://github.com/Gbuomprisco/ngx-chips

数据来自http服务(Observable)。

我在文档中找不到在使用 ngx-chips 执行 rest 调用之前指定最小文本长度的方法。

我的 html 片段是

<tag-input name="tagList" [addOnBlur]="true" formControlName="tagList"  theme='bootstrap' [clearOnBlur]="true" [onlyFromAutocomplete]="false" onTextChangeDebounce="100">
   <tag-input-dropdown [autocompleteObservable]="requestTags" >
</tag-input-dropdown>

我的 requestTags 函数是:

public requestTags = (text:string ) =>{
    return this.resourceService.findMatchingTags(text);
};

谢谢

看源码好像tag-input-dropdown有个输入属性 minimumTextLength 是为了显示自动完成下拉列表而不执行 Observable 调用的最小文本长度。 可以按如下方式使用:

<tag-input name="tagList" [addOnBlur]="true" formControlName="tagList"  theme='bootstrap' [clearOnBlur]="true" [onlyFromAutocomplete]="false" onTextChangeDebounce="100">
   <tag-input-dropdown [autocompleteObservable]="requestTags" [minimumTextLength]="2">
</tag-input-dropdown>