Can't select item in list created by ui-select2

后端 未结 3 1705
别那么骄傲
别那么骄傲 2021-02-13 20:47

In my HTML I have this line:


相关标签:
3条回答
  • 2021-02-13 20:58

    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

    0 讨论(0)
  • 2021-02-13 21:03

    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; }
        ...
    }; 
    
    0 讨论(0)
  • 2021-02-13 21:05

    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}
    
    0 讨论(0)
提交回复
热议问题