Can't select item in list created by ui-select2
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
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}
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; } ...};