好吧,我是在项目中第一次使用ui-select
插件。
当用户键入搜索输入时,我正在调用refresh
属性。如果没有refresh
属性,它可以正常工作,那么我仍然可以看到带有所选项目的下拉列表。
但是在refresh
调用之后从检索到的列表中选择项目时,该列表为空白。点击
这是html代码:
<ui-select ng-model="noPostData.locaopt.id" theme="select2" on-select="validDropDown()">
<ui-select-match placeholder="Select location">{{$select.selected.name}}
</ui-select-match>
<ui-select-choices refresh="locationSearchData($select.search)" refresh-delay="0" minimum-input-length="2"
repeat="obj.id as obj in locaoptions">
<div ng-bind-html="obj.name"></div>
</ui-select-choices>
</ui-select>
这是控制器代码:
$scope.locationSearchData=function(char) {
singleservice.getTableDetails("/location/list?fields=id,name&filter[name]="+char+"%&per-page=100","GET")
.then(function (response){
$scope.locaoptions=response;
console.log(response);
});
}//this is called when refresh is called from ui-select on search input text change
singleservice.getTableDetails($scope,"/location/list?fields=id,name","GET")
.then(function (response){
$scope.locaoptions=response;
}); //this is just called for initial data loading in dropdown
我不知道出了什么问题。也许与refresh
attr有关。请帮助我解决此问题并学习新知识。