abhit
abhit

Reputation: 981

How to use autocomplete with ng-tags-input in AngularJs?

I have a ng-tag field like:

<tags-input ng-model="services"></tags-input>

I would like to add autocomplete feature without using jquery on this field.

The data for autocomplete will be a local json object.

How can I do that?

Upvotes: 0

Views: 3093

Answers (1)

Brian Liu
Brian Liu

Reputation: 341

Here is a quick example, you just need to create <auto-complete> inside <tags-input> then assign source

<tags-input max-tags="{{tab.maxTags}}"
                    min-length="1"
                    key-property="tag"
                    display-property="tag"
                    template="tagItem.html"
                    data-ng-model="tab.series.tags"
                    replace-spaces-with-dashes="false"
                    data-ng-class="{'hide-tags-input': tab.series.tags.length >= tab.maxTags}">
            <auto-complete min-length="1"
                           load-on-focus="true"
                           load-on-empty="true"
                           display-property="tag"
                           select-first-match="false"
                           template="autocomplete.html"
                           source="tab.autocomplete($query)">
            </auto-complete>
        </tags-input>

Upvotes: 2

Related Questions