Skip to content

Instantly share code, notes, and snippets.

@mockguiver
Created June 12, 2013 14:53
Show Gist options
  • Save mockguiver/5766000 to your computer and use it in GitHub Desktop.
Save mockguiver/5766000 to your computer and use it in GitHub Desktop.
Angular JS - $resource - Avoid CORS using JSONP
// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('myBeerApp.services', ['ngResource']).
value('version', '0.1').
factory('beerDB', function($resource) {
return $resource('URL',{
alt:'json',
appToken:'TOKEN',
q:'rock',
callback: 'JSON_CALLBACK'
},
{
get: {
method:'JSONP',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment