Search code examples
angularjsng-tags-input

ngTagsInput - only allow selection of autocomplete suggestions?


If you are pulling from a source of

[{text: 'a'}, {text: 'ab'}, {text: 'abc'}]

and user enters in 'abcd', how do you prevent user from creating an 'abcd' tag?


Solution

  • Just set the addFromAutocompleteOnly to true and only suggestions coming from the autocomplete popup will be allowed to be added as tags.

    <tags-input ng-model="tags" add-from-autocomplete-only="true">
      <auto-complete source="loadTags($query)"></auto-complete>
    </tags-input>
    

    Plunker