Currently facing an issue with my grocery list item app developed in AngularJS. I have simulated a connection to a server via AJAX requests made to local JSON files.
One of the files returns a fake server status like this:
[{
"status": 1
}]
I am attempting to retrieve the value of this status using the following code:
groceryService.save = function(entry){
var updatedItem = groceryService.findById(entry.id);
if(updatedItem){
$http.post("data/updated_status.json", entry)
.success(function(data){
if(data.status == 1){
updatedItem.completed = entry.completed;
updatedItem.itemName = entry.itemName;
updatedItem.date = entry.date;
}
})
.error(function(data,status){
});
} else {
// Creating new item
}
However, I am unable to access the status value and I'm unsure why. There are no error codes in the Chrome Browser console. It seems that AngularJS might be transforming the JSON data format which is causing issues with accessing it. Any insight on how to properly handle this?
I initially suspected that AngularJS was converting the integer 1 to a string but my test proved otherwise.
I have included the $http service in my directive:
app.service("GroceryService", function($http){
The application is being run on a xampp local server.
Your assistance in resolving this matter would be greatly appreciated :-).
Thank you!