Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 520
c0de Avatar asked Dec 19 '22 20:12

c0de


1 Answers

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

like image 122
Michael Benford Avatar answered Mar 23 '23 03:03

Michael Benford