无法在 ui-select2 创建的列表中选择项目 [英] Can't select item in list created by ui-select2
本文介绍了无法在 ui-select2 创建的列表中选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 HTML 中有这一行:
In my HTML I have this line:
<input ng-change="privChanged()" ng-model="selectedPriv" ui-select2="privsSelect2options"></input>
和 privsSelect2options
函数:
$scope.privsSelect2options = {
placeholder: "Wybierz privo",
allowClear:true,
minimumInputLength: function(){return 3;},
formatInputTooShort: function (input, min) {return "Wprowadź conajmniej " + min + " znaki.";},
formatSearching: function () { return "Wyszukiwanie..."; },
formatNoMatches: function () { return "Nie znaleziono pasujących województw."; },
query: function (query) {
query.callback( {results: $filter('filter')($scope.privs,{name: query.term}) } );
},
formatResult: function(priv){
return priv.name;
},
formatSelection: function(priv){
return priv.name;
}
};
当我输入 3 个字母时,一切正常,它会过滤结果并显示正确,但我无法单击并从结果列表中选择任何项目.任何人都可以帮我解决这个问题吗?它甚至没有进入 formatSelection
函数.
Everything works OK when I put 3 letters it filters the result and shows it correct but I can't click and select any item from the result list. Can anyone help me in this matter? It doesn't even come into the formatSelection
function.
推荐答案
问题是Priv
类/表没有 id 属性,其主键是字段代码.我必须添加功能:
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;
},
在$scope.privNameSelect2options
这篇关于无法在 ui-select2 创建的列表中选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文