【发布时间】:2017-03-30 09:13:43
【问题描述】:
我正在尝试使用异步预输入,我可以很好地获取数据,并且检查器清楚地显示正在返回的数据。例如我正在使用getLocation的引导示例
$scope.getLocation = function(val) {
return $http.get('//maps.googleapis.com/maps/api/geocode/json', {
params: {
address: val,
sensor: false
}
}).then(function(response){
return response.data.results.map(function(item){
return item.formatted_address;
});
});
};
这正是我希望它工作的方式,然后这就是我的方法。
$scope.filterClients =function(val) {
var data = $.param({
action: "filter_clients",
value: val
});
var config = {headers : {'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'}}
$http.post('http://***************.co.uk/switchboard.php', data, config)
.then(function (response) {
return response.data.map(function(item){
return item.first_name;
});
});
};
HTML 代码
<input ng-model="asyncSelected" placeholder="Select a Client" uib-typeahead="first_name for first_name in filterClients($viewValue)" class="form-control"/>
【问题讨论】:
-
显示html代码
-
@sachilaranawaka html 提供
-
在http post请求前面也加一个return
标签: javascript php angularjs json