Ng tags that do not allow you to enter the same text twice in a text field

I use ng tag input to autocomplete if autocomplete returns the result of the same text, for example: two results are filled when I type β€œR”, β€œRob”, β€œRob” like this.

I clicked on one β€œRob”, now it is in the text box, but when I type β€œR” again, β€œRob” does not fit. How to ensure uniqueness for each item in the list.

+4
source share
1 answer

Tags are unique by default with their text property (here "Rob"). You can change this with the "keyProperty" attribute by setting it with a unique Rob identifier.

<tags-input
    ng-model="users"
    key-property="_id"
    display-property="username">
 </tags-input>

http://mbenford.imtqy.com/ngTagsInput/documentation/api

+3
source

All Articles