In my HTML I have this line:
the problem was that Priv
class/table didn't have id property, and its Primary Key was field code. I had to add function :
id : function(priv) {
return priv.code;
},
in $scope.privNameSelect2options
Although this isn't really specified in the select2 documentation, you'll need to pass an id key with a function value to select2.
$scope.privsSelect2options = {
id: function(element) { return element.name; }
...
};
Please refer to Select2 Ajax Method Not Selecting,
and take the correct value:
id: function(data){return {id: data.id};},
or
id: function(data){return data.id}