{"id":115,"date":"2015-03-05T01:16:02","date_gmt":"2015-03-05T01:16:02","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=115"},"modified":"2015-03-11T17:08:16","modified_gmt":"2015-03-11T17:08:16","slug":"angularjs-ngtagsinput-v2-2-0-duplicates-in-a-repeater-are-not-allowed","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=115","title":{"rendered":"Angularjs &#8211; ngTagsInput v2.2.0 &#8211; &#8220;Duplicates in a repeater are not allowed.&#8221;"},"content":{"rendered":"<p>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.<\/p>\n<p><code>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<\/code><\/p>\n<p>If you experience this error, search and find the following.<\/p>\n<p><code>tag in tagList.items track by track(tag)<\/code><br \/>\n<code>item in suggestionList.items track by track(item)<\/code><br \/>\nReplace it with the code below.<\/p>\n<p><code>tag in tagList.items track by $index<\/code><\/p>\n<p>This allows Angular to keep track of the items in the repeat.<\/p>\n<p><code>item in suggestionList.items track by $index<\/code><\/p>\n<p><a href=\"http:\/\/mbenford.github.io\/ngTagsInput\">ngTagsInput<\/a><\/p>\n<p><a href=\"https:\/\/docs.angularjs.org\/api\/ng\/directive\/ngRepeat\">ngRepeat<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;track by&#8217; expression [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":8,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}