How to access couchdb cross domain from angularjs

Question!

I've set up a local environment, where I load data from a json file:

var Players = $resource('data/players.json');
var players = Players.query(function(){});

And it works great.

Now I want to access a CouchDB on a different domain (http://playball.iriscouch.com/players), and based on the google buzz example I've tried the following, but I can't make it work:

var Players = $resource('http://playball.iriscouch.com/players',  
  {alt: 'json', callback: 'JSON_CALLBACK'},
  {get:     {method: 'JSON'}
});

var players = Players.query(function(){});

I simply receive an empty array... Any ideas?

Thanks a buch!

Sune



Answers

If you have control over the server, use CORS.

To correct your example:

var Players = $resource('http://playball.iriscouch.com/players',

  // These params will be set to each request (?alt=json
By : Vojta


This video can help you solving your question :)
By: admin