我正在使用 ngTagInput 库引用: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
请提出建议。
最佳答案
该功能现已在 master branch 中可用GitHub 上的项目。你可能想在它上面重新设置你的 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 将使指令在输入内容变为空时调用加载函数,将 loadOnFocus
设置为 true 将在输入获得焦点时执行相同的操作.
关于angularjs-directive - 当 minLength 为 0 ngInputTag 时如何显示下拉列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24753069/