I have a json file named db.json which is like
{
"menu":[
{
"id":0,
"item":"item1"
},{
"id":1,
"item":"item2"
},{
"id":2,
"item":"item3"
}
],
"feedback":[]
}
I am using angular $resource
to PUT
an Javascirpt object into the feedback
array.
Here is my service code-
this.getFeedbacks = function(){
return $resource(baseURL + "feedback/:id", null, {
'update': {
method: 'PUT'
}
});
};
And here is the controller code-
$scope.fb.push($scope.myFeedback);
menuFactory.getFeedbacks().update({
id: $scope.fb.id
}, $scope.fb);
Notice that the feedback
array in the json is empty and the $scope.myFeedback is found from a ng-controller's ng-model and this ng-controller has a submit button when I click on the submit button then the values of the inputs are stored into the json file.
The HTML code is-
<form name="feedbackForm" ng-submit="setFeedback()">
<input type="text" name="name" ng-model="myFeedback.name">
<input type="submit" name="submit" value="feedback">
</form>
My update function is not working why please someone explain it. Note that I am very beginner at angularJS platform and REST client-server networking.
baseUrl
? – charlietfl 22 hours ago