My understanding is that in Angular, the HTTP service has two checks for 'success' and 'error' when connecting to a service. I have already handled these checks as my first step.
The issue I am facing now is with the data in my JSON file. It contains a 'success' state which indicates if there are any problems with the data received from the form. In case of errors, there will be an error object that needs to be displayed to the user.
I need to check for the value of 'success', but I'm not sure where the best place to do this would be. Should it be done in the controller?
Since the correct data is essential for the page to function properly, checking for 'success' should be one of the first tasks after retrieving the data.
Here's a basic layout of the controller:
app.controller("dataCtrl", function ($scope, $http) {
$http.post('/getdata').success(function (data) {
$scope.businessData = data;
// Should I be checking businessData.success at this level?
}).error(function () {
alert("Problem");
});
});