My factory for making request is here:
angular.module('myapp').factory('testResponse',
['$http', '$resource', 'AppConfig', '$routeParams', '$rootScope',
function($http, $resource, $routeParams, $rootScope) {
$http.defaults.headers.common['Authorization'] = authorizationHeader;
$http.defaults.headers.post['Content-Type'] = 'application/json';
return $resource('test.json'), {}, {
query: {method: 'GET'}
};
}]);
The code in controller is here:
angular.module('myapp').controller('TestCtrl',
['$http', '$scope', 'testResponse', 'AppConfig', function TestCtrl($http, $scope, testResponse) {
testResponse.query(function(data) {
console.log(data.status);
})
}]);
Ideally it should log the status as in $http request but I am unable to get it for $reource
$resource
should not be used... accessing the status code on success is not an unusual scenario... this data should be made available by default, not hidden from you – Launalaunce