Angularjs – ngTagsInput v2.2.0 – “Duplicates in a repeater are not allowed.”

ngTagsInput is a great tags input directive for Angularjs. It auto suggests tags from an external source and populates them into an input for form submission. While using it, I discovered that having multiple instances on a form caused an angularjs error.

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: tag in tagList.items track by track(tag), Duplicate key

If you experience this error, search and find the following.

tag in tagList.items track by track(tag)
item in suggestionList.items track by track(item)
Replace it with the code below.

tag in tagList.items track by $index

This allows Angular to keep track of the items in the repeat.

item in suggestionList.items track by $index

ngTagsInput

ngRepeat

2 thoughts on “Angularjs – ngTagsInput v2.2.0 – “Duplicates in a repeater are not allowed.”

Leave a Reply to wandertosee Cancel reply

Your email address will not be published. Required fields are marked *