In the following callback function in my angular JS app, I want only the values to be added in array addresses[ ] that have the value of val in the funtion parameter. This is basically for the function to return values suggested based of string match from my json:
$scope.getAirports = function(val) {
return $http.get('https://raw.githubusercontent.com/vedvasa/airports/master/airports.json', {
params: {
address: val,
sensor: false
}
}).then(function(res){
var addresses = [];
angular.forEach(res.data.records, function(item){
addresses.push(item.code);
});
return addresses;
});
};