When using the $resource .query method in my Angular.js app to send a query, I am encountering an issue where the characters of the query string are being submitted as separate parameters. Why is this happening?
Below is the unexpected result:
cities?0=n&1=e&2=w&3=y&4=o&country_code=US
Here is the relevant code snippet:
// Defines Cities service with REST endpoint
angular.module('mean.cities').factory("Cities", ['$resource', function($resource) {
return $resource('cities/:query', {
query:'@query',
country_code: 'US'
},
{});
}]);
// Controller Method for autocompleting cities
$scope.autocompleteCity = function(query) {
Cities.query($scope.query, function(cities) {
console.log(cities);
});
};
// UI Element for city autocomplete input
<input auto-complete ui-items="names" ng-model="query" class="form-control input-lg" placeholder="Enter A Town" ng-change="autocompleteCity()">