Created
November 24, 2013 11:53
-
-
Save unkleara/7626371 to your computer and use it in GitHub Desktop.
geobytes service angularjs and lodash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('geoData', ['$http', '$q', 'limitToFilter', function ($http, $q, limitToFilter) { | |
return { | |
get: function(inputValue) { | |
var url = "http://gd.geobytes.com/AutoCompleteCity?callback=JSON_CALLBACK &filter=US&q="; | |
//since $http.get returns a promise, | |
//and promise.then() also returns a promise | |
//that resolves to whatever value is returned in it's | |
//callback argument, we can return that. | |
return $http.jsonp(url + inputValue) | |
.then(function (result) { | |
return limitToFilter(_.map(result.data, function(v) { | |
return v.replace(', United States','')}), 10); | |
}); | |
} | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment