make auto-complete searchable下拉列表不希望在搜索时单击时显示列表

时间:2016-05-10 08:29:14

标签: javascript jquery html angularjs drop-down-menu

fiddle link

<div ng-app="app" ng-controller="myCtrl as vm">
 <ui-select tagging ng-model="vm.selected" theme="bootstrap">
  <ui-select-match p laceholder="Pick one...">{{$select.selected.value}}</ui-select-match>
    <ui-select-choices repeat="val in vm.values | filter: $select.search">
      <span ng-bind-html="val.value | highlight: $select.search"></span>
    </ui-select-choices>
 </ui-select>
</div>


var app = angular.module('app', ['ui.select', 'ngSanitize']);

app.controller("myCtrl", function() {
 vm = this;
 vm.isLoaded = false;
 vm.values = [{
  'key': 22,
  'value': 'Kevin'
 }, {
  'key': 24,
  'value': 'Fiona'
 }];
 vm.selected;
});

这工作正常,但现在我想在搜索时显示列表,不想在搜索框中单击搜索词时显示

1 个答案:

答案 0 :(得分:0)

fiddle link

经过大量实验,我找到了问题的答案

var app = angular.module('app', ['ui.select', 'ngSanitize']);

app.controller("myCtrl", function() {
vm = this;

vm.funcAsync = function(query) {

    if (query === null || query === ""|| query.length<1) {
        return;
    }

 vm.isLoaded = false;
 vm.values = [{
 'key': 22,
 'value': 'Kevin'
  }, {
 'key': 24,
 'value': 'Fiona'
  }];
  vm.selected;

 };

});