答案 0 :(得分:0)
您应该考虑创建自己的自定义指令或使用现有的指令https://github.com/guylabs/ion-autocomplete
答案 1 :(得分:0)
这是我使用的自动完成的代码片段,但我需要名字和姓氏搜索(不应搜索随机字母) -
var airlines = [{“fs”:“LCI”,“iata”:“LF”,“icao”:“LCI”,“name”:“Lao Central Airlines”,“active”:true},{ “FS”: “TGU”, “国际航协”: “5U”, “国际民航组织”: “TGU”, “名”: “TAG”, “主动”:真正},{ “FS”: “BT”,“国际航空运输协会“:”BT“,”icao“:”BTI“,”name“:”Air Baltic“,”active“:true},{”fs“:”9J“,”iata“:”9J“,”icao“ :“DAN”,“name”:“Dana Airlines”,“active”:true},{“fs”:“2O”,“iata”:“2O”,“icao”:“RNE”,“name”: “Island Air Service”,“active”:true},{“fs”:“NPT”,“icao”:“NPT”,“name”:“Atlantic Airlines”,“active”:true},{“fs” :“C8”,“iata”:“C8”,“icao”:“ICV”,“name”:“Cargolux Italia”,“active”:true},{“fs”:“FK”,“iata”: “FK”,“icao”:“WTA”,“name”:“Africa West”,“active”:true},{“fs”:“8K”,“iata”:“8K”,“icao”:“ EVS“,”名称“:”EVAS Air Charters“,”active“:true},{”fs“:”W8“,”iata“:”W8“,”icao“:”CJT“,”name“:” Cargojet“,”活跃“:true},{”fs“:”JBW“,”iata“:”3J“,”icao“:”JBW“,”name“:”Jubba Airways(肯尼亚)“,”活跃“ :真正},{ “FS”: “TNU”, “国际航协”: “M8”, “国际民航组织”: “TNU”, “名”: “TransNusa”, “主动”:真正},{ “FS”:” HCC“,”iata“:”HC“,”icao“:”HCC“,”name“:”Holidays Czech Airlines“,”active“:true},{”fs“:”A PJ“,”iata“:”MM“,”icao“:”APJ“,”name“:”Peach Aviation“,”active“:true},{”fs“:”TUY“,”iata“:”L4 ”, “国际民航组织”: “TUY”, “名”: “LTA”, “主动”:真正},{ “FS”: “LAE”, “国际航协”: “L7”, “国际民航组织”: “LAE” “名”: “LANCO”, “主动”:真正},{ “FS”: “L5 *”, “国际航协”: “L5”, “国际民航组织”: “LTR”, “名”: “勒夫特运输航空公司”,”主动 “:真正},{” FS “:” 质量保证”, “国际航协”: “质量保证”, “国际民航组织”: “CIM”, “名”: “辛伯”, “主动”:真正},{ “FS” :“KBZ”,“iata”:“K7”,“icao”:“KBZ”,“name”:“Air KBZ”,“active”:true},{“fs”:“L2”,“iata”: “L2”,“icao”:“LYC”,“name”:“Lynden Air Cargo”,“active”:true},{“fs”:“MPK”,“iata”:“I6”,“icao”: “MPK”,“名称”:“Air Indus”,“active”:true},{“fs”:“CAO”,“icao”:“CAO”,“name”:“Air China Cargo”,“active” :true},{“fs”:“BEK”,“iata”:“Z9”,“icao”:“BEK”,“name”:“Bek Air”,“active”:true},{“fs”: “IAE”, “国际航协”: “IO”, “国际民航组织”: “IAE”, “名”: “IrAero”, “主动”:真正},{ “FS”: “GL *”, “国际航协”:” GL“,”name“:”Airglow Aviation Services“,”active“:true},{”fs“:”ATN“,”iata“:”8C“,”icao“:”ATN“,”name“:” ATI“,”活跃“:true},{”fs“:”GU“,”iata“:”GU“,”icao“:”GUG“,”name“:”Aviateca Guatemala“,”active“:true} { “FS”: “GHY”, “国际民航组织”:” GHY“,”name“:”German Sky Airlines“,”active“:true},{”fs“:”SS“,”iata“:”SS“,”icao“:”CRL“,”name“:”海盗船“,”活跃“:真实},{”fs“:”XK“,”iata“:”XK“,”icao“:”CCM“,”名称“:”科西嘉航空“,”活跃“:真实} ,{“fs”:“W9 *”,“iata”:“W9”,“icao”:“JAB”,“name”:“Air Bagan”,“active”:true},{“fs”:“Z8 *”, “国际航空运输协会”: “Z8”, “ICAO”: “AZN”, “名称”: “Amaszonas”, “活性”:真},{ “FS”: “D2”, “国际航空运输协会”: “D2” ,“icao”:“SSF”,“名称”:“Severstal Aircompany”,“active”:true},{“fs”:“SNC”,“iata”:“2Q”,“icao”:“SNC”, “名称”:“航空货运航空公司”,“活跃”:真实},{“fs”:“PST”,“iata”:“7P”,“icao”:“PST”,“名称”:“巴拿马航空” ,“active”:true},{“fs”:“VV”,“iata”:“VV”,“icao”:“AEW”,“name”:“Aerosvit Airlines”,“active”:true},{ “FS”: “UJ”, “国际航协”: “UJ”, “国际民航组织”: “LMU”, “名”: “AlMasria”, “主动”:真正},{ “FS”: “9U”,“国际航空运输协会“:”9U“,”icao“:”MLD“,”name“:”Air Moldova“,”active“:true},{”fs“:”NF“,”iata“:”NF“,”icao“ :“AVN”,“name”:“Air Vanuatu”,“phoneNumber”:“678 238 48”,“active”:true},{“fs”:“NJS”,“iata”:“NC”,“icao” “:”NJS“,”名称“:”Cobham Aviation“,”active“:true}];
airlines = airlines.sort(function(a,b){
var airlineA = a.name.to();
var airlineB = b.name.toLowerCase();
if(airlineA > airlineB) return 1;
if(airlineA < airlineB) return -1;
return 0;
});
的console.log(航空公司);
angular.module('ionicApp',['ionic'])
.factory('FlightDataService',函数($ q,$ timeout){
var searchAirlines = function(searchFilter) {
console.log('Searching airlines for ' + searchFilter);
var deferred = $q.defer();
var matches = airlines.filter( function(airline) {
if(airline.name.toLowerCase().indexOf(searchFilter.toLowerCase()) !== -1 ) return true;
})
$timeout( function(){
deferred.resolve( matches );
}, 100);
return deferred.promise;
};
return {
searchAirlines : searchAirlines
}
})
.controller('MyCtrl',['$ scope','FlightDataService',函数($ scope,FlightDataService){
$scope.myTitle = 'Auto Complete Example';
$scope.data = { "airlines" : [], "search" : '' };
$scope.search = function() {
FlightDataService.searchAirlines($scope.data.search).then(
function(matches) {
$scope.data.airlines = matches;
}
)
}
}]);