I'm sending this parameter (year) from a select element and I'm using the $http service in order to list an array of objects based on the parameter but for some reason it does not work.
I have the 404 (Not Found) error because the parameter does not appear in the url in order to make the request.
Select element:
<select data-ng-model="year" data-ng-change="listByYear(year)">
<option value="">Select year</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
Controller appController and fuction listByYear():
moduleApp.controller("appController", function($scope, $http){
$scope.listByYear = function(year){
console.info("Parameter received: "+year)
var parameter = {
year: $scope.year
};
var config = {
param: parameter
};
$http.get("/pro/users/listByYear", config)
.success(function (data, status, headers, config) {
$scope.users = data;
console.info("Ok")
}).error(function (data, status, header, config) {
console.error("Error")
});
}
});