Skip to content

Instantly share code, notes, and snippets.

@unkleara
Created November 24, 2013 11:53
Show Gist options
  • Select an option

  • Save unkleara/7626371 to your computer and use it in GitHub Desktop.

Select an option

Save unkleara/7626371 to your computer and use it in GitHub Desktop.

Revisions

  1. unkleara created this gist Nov 24, 2013.
    16 changes: 16 additions & 0 deletions formData.js
    Original 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);
    });
    }
    }
    }]);