Created
November 24, 2013 11:53
-
-
Save unkleara/7626371 to your computer and use it in GitHub Desktop.
Revisions
-
unkleara created this gist
Nov 24, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ 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); }); } } }]);