Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngTagsInput "ngrepeat: dupes" and "Cannot read property 'replace' of undefined"

I am attempting to use autocomplete inside ngTagsInput and I am getting the following errors:

Error: [ngRepeat:dupes] http://errors.angularjs.org/1.2.9/ngRepeat/dupes?p0=item%20in%20suggestionList.items%20track%20by%20track(item)&p1=undefined
    at Error (native)

OR

TypeError: Cannot read property 'replace' of undefined
    at j (https://localhost:3000/js/plugins/ng-tags-input.min.js:1:5556)

I have checked several time that my querying function is returning a proper array of tags, and it is. It works beautifully. The structure of a tag looks like:

{ 
name: String, 
_id: ObjectId, 
__v: Number, 
active: Boolean, 
display: Boolean, 
createDate: Date
}

My html looks like:

<tags-input
    ng-model="tags"
    displayProperty="name"
    placeholder="Add a tag">
    <auto-complete source="loadTags($query)"></auto-complete>
</tags-input>

And my loadTags function is:

$scope.loadTags = function(query) {

    return $http.get(configService.getApi() + '/tags?conditions=' + urlEncodeObject({name: { $regex: query }}), {
        headers: {
            'x-auth-token': sessionService.getToken()
        }
    });
};
like image 435
Rob Allsopp Avatar asked Jul 31 '14 04:07

Rob Allsopp


1 Answers

displayProperty should have been display-property. Doh!

like image 97
Rob Allsopp Avatar answered Dec 07 '22 20:12

Rob Allsopp