我正在使用ngTagInput库ref:http://mbenford.github.io/ngTagsInput/,我根据我的要求进行了一些定制。
现在,我希望只要输入被聚焦,下拉就会显示已提取的数据。
E.g.
users = ["stack" ,"subj" ,"owner"];
1. Now on focusing input ("Add User"), all three users should be fetched.
2. After I input "s",then, only "stack" and "subj" should be shown.
For that, I tried ng-focus= "newTagChange()" instead of ng-change="newTagChange()".
But it didn't work as expected.
I also tried with minLength="0" which failed as well.
在Plunker
http://plnkr.co/edit/shgh40H3Nc0eEeM4Lidd?p=preview
请建议。
答案 0 :(得分:4)
该功能现已在GitHub项目的master branch中提供。您可能希望在它之上重新设置fork。
以下是如何启用该行为:
<tags-input ng-model="tags">
<auto-complete source="loadTags($query)"
load-on-empty="true"
load-on-focus="true">
</auto-complete>
</tags-input>
将loadOnEmpty
设置为true将使指令在输入内容变空时调用load函数,并且当输入获得焦点时,将loadOnFocus
设置为true将执行相同的操作。