I'm trying to use select2 tags drop-down.
I call the API which sends me data. I put the data into select2 like this :
AssignmentProvider.getStudentsInCourse(COURSENAME,SEMESTER)
.success(function(data) {
$scope.select2OptionsForGroups = {
'multiple': true,
'simple_tags': true,
'formatResult': formatResult,
'formatSelection': formatResult,
'tags': data
};
})
.error(function(e) {
// TODO: Error handling
console.log("error");
});
data being array with objects of students, so I fetch the Names inside the object with this.
function formatResult(student) {
return student.id.Student.FullName;
};
Everythings works perfect when I select the first name from the dropdown list, but when I try to select the second it's like there is nothing in the list to select but if I remove my existing selection all the names come back in.
Here I'm select the second one and nothing happens :
and here is when I have not selected anyone.
It's displays the names when I click but when I enter in search term is shows
Uncaught TypeError: Cannot read property 'FullName' of undefined
Updated:
Has anyone any idea what might be wrong here, I'm guessing I need to tell the select2 to search for the term inside the object but how?
My initial guess would be that you have some data entries where Student is undefined