2014-07-17 42 views
0

任何人都可以請告訴我如何創建一個可編輯的搜索框,(不自動完成),因爲在自動完成時,只有當我們鍵入選擇出現,但在這種情況下,當我們沒有輸入任何所有選項將顯示爲下拉菜單,以及當我們輸入任何顯示的選項時,應該根據該選項進行過濾AngularJS選擇與自動完成功能

應該像自動完成一樣運行以及像select一樣。

誰能告訴我,這

Working Demo

HTML一些解決方案

<select ng-model="names" ng-options="person.name for person in persons | orderBy:'name'" ng-change="select()"> 
</select> 

腳本

var app = angular.module('myApp', []); 

app.controller('Controller', function ($scope) { 
    $scope.persons = [{ 
     "uid": 1171, 
      "name": "Mary", 
      "description": "Mary" 
    }, { 
     "uid": 1172, 
      "name": "John", 
      "description": "John" 
    }, { 
     "uid": 1173, 
      "name": "Sunny", 
      "description": "Sunny" 
    }, { 
     "uid": 1174, 
      "name": "Jacob", 
      "description": "Jacob" 
    }, { 
     "uid": 1175, 
      "name": "Susan", 
      "description": "Susan" 
    }, { 
     "uid": 1176, 
      "name": "Supriya", 
      "description": "Supriya" 
    }, { 
     "uid": 1177, 
      "name": "Sumaya", 
      "description": "Sumaya" 
    }]; 
}); 
+0

嘗試jQuery的選擇,具有一個角指令:http://plnkr.co/edit/HbPVSWb9nvV2ecHibaXw?p=preview – Raghavendra

回答

2

聽起來像ui-select

演示here - 請參閱上一個選擇框。

例如:

<ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;"> 
    <ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match> 
    <ui-select-choices repeat="country in countries | filter: $select.search"> 
    <span ng-bind-html="country.name | highlight: $select.search"></span> 
    <small ng-bind-html="country.code | highlight: $select.search"></small> 
    </ui-select-choices> 
</ui-select> 
+0

但在IE 8 –

+0

這不會工作我總是說: IE用戶已經習慣了網絡被破壞,爲什麼要關心?但是,嚴重的是,如果你絕對需要支持IE8,那麼我想你會在你自己的指令中包裝一些JQuery插件。 – user2847643