I am using json-server and db.json, in db.json file I have a currently empty array "feedback":[] where user should be able to send feedbacks from the app.
but nothing get pushed into server, the get method works (GET from server) but no PUT
this is my service:
angular.module('confusionApp')
.constant("baseURL", "http://localhost:3000/")
.service('feedbackService',['$resource','baseURL',function($resource,baseURL){
this.getFeedback=function(){
return $resource(baseURL+"feedback/",null,{
'update':{
method:'PUT'
}
});
};
}]);
and this is the controller: the contactus.html contains a feedback form and hence has two controllers
// contactus.html controllers
.controller('ContactController', ['$scope', function($scope) {
$scope.feedback = {
firstName: "",
lastName: "",
email: "",
date:""
};
}])
// Feedback form controller
.controller('FeedbackController', ['$scope','feedbackService', function($scope,feedbackService) {
$scope.feedbacks=feedbackService.getFeedback().query();
$scope.sendFeedback = function() {
$scope.feedback.date=new Date().toISOString();
$scope.feedbacks.push($scope.feedback);
$scope.feedbackForm.$setPristine();
$scope.feedback = {
firstName: "",
lastName: "",
email: "",
date:""
};
};
}])