将下拉列表更改为角度js中的可搜索下拉列表

时间:2016-04-14 12:37:45

标签: javascript jquery html angularjs

html代码

<div style="position: absolute" class="container-fluid typeahead-demo" ng-controller="TypeaheadCtrl">
  <input type="text" ng-model="customSelected" placeholder="Custom template" uib-typeahead="state as state.name for state in states | filter:{name:$viewValue}" class="form-control" typeahead-show-hint="true" typeahead-min-length="0">
  <select ng-model="selected_person" ng-options="person.name for person in states | filter: customSelected">
    <option value="">Choose a Name</option>
  </select>
</div>

angularjs代码

var treectrl = angular.module('mapsApp', []);

treectrl = treectrl.controller('TypeaheadCtrl', function ($scope) {
  $scope.states = [
    {
      name: "Alabama",
      child: ["Alabama1child", "Alabama2child", "Alabama3child"]
    }, 
    {
      name: "Alaska",
      child: ["Alaska1child", "Alaska2child"]
    }
  ];
});

这是我的代码,现在我不想使用输入type="text" 只想在下拉列表中搜索下拉列表的顶部用作搜索,当点击其打开时搜索到的单词

0 个答案:

没有答案