angularjs-directive - 当 minLength 为 0 ngInputTag 时如何显示下拉列表?

标签 angularjs-directive typeahead ng-tags-input

我正在使用 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/

相关文章:

javascript - AngularJs:自定义指令的动态模板不替换属性值

javascript - 使用 Bootstrap Typeahead 的荧光笔替代方案

javascript - AngularJS 1.x NgTagsInput 显示消息

AngularJS:指令隔离范围 - 范围变量未定义

javascript - AngularJS V1.4.7指令templateUrl动态路径

php 如果在 javascript 中

javascript - Geonames JSONP 结果未显示在下拉列表中

javascript - ng-tagsInput 不工作

javascript - 指令中的 AngularJS 模板函数给出错误 'Template for directive must have exactly one root element'