minLength为0 ngInputTag时如何显示下拉列表?

时间:2014-07-15 08:11:28

标签: angularjs-directive typeahead ng-tags-input

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

查找当前的实施情况

请建议。

1 个答案:

答案 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将执行相同的操作。