I have defined two services in AngularJS that should both return JSONP for a cross domain request.
Service A:
angular.module('ServiceA', ['ngResource']).
factory('A', function ($resource) {
return $resource('url/offers', {},
{
get: { method: 'JSONP', params: {property_code: 'DEMO_ERFOLGX', adults: '2',
callback: 'JSON_CALLBACK'} }
}
);
});
Service B:
angular.module('ServiceB', ['ngResource']).
factory('B', function ($resource) {
return $resource('url/search.json', {},
{
get: { method: 'JSONP', params: {property_code: 'DEMO_ERFOLGX', adults: '2',
callback: 'JSON_CALLBACK'} }
}
);
});
The results are then bound to the scope in my Controller:
$scope.foo = A.get();
$scope.bar = B.get();
After checking the console.log() output, it seems that B returns the expected JSON format, while A returns an error:
SyntaxError: invalid label
{"DEMO_ERFOLGX":{"offers":[{"checkin":"2012-12-01","checkout"
I am not sure what I am missing. How can I ensure that A returns the proper JSON format?