This should work -
Service:
mobilityApp.service('serveiWebservices', function($http) {
return {
getWS: function() {
var path = 'jsonWS/context.json';
return $http.get(path, function (response) {
console.log(JSON.stringify(response, null, 4));
return response.data;
});
}
};
});
Controller:
serveiWebservices.getWS().then(function(data) {
console.log(JSON.stringify(data, null, 4));
});
If you want to use $resource
this should work too -
mobilityApp.service('serveiWebservices', function($resource) {
return {
getWS: function() {
var path = 'jsonWS/context.json';
return $resource(path).get(function (response) {
console.log(JSON.stringify(response, null, 4));
return response; // might just be response, no response.data
});
}
};
});