3

I'm a beginer using angular js. It's been great so far though I got into this issue trying to query flickr public photos using their json api. Here is the url.

If you clck there you'll see the json response just fine. Though when I try to print the results on the template using {{flickrResult}} I only get {} printed, and when I check the console for errors I get "jsonFlickrFeed is not defined" which is part of the json that flickr provides.

Here is the code of my controller:

angular.module('Flickr', ['ngResource']);
function FlickrCtrl($scope, $resource){

$scope.flickr = $resource('http://api.flickr.com/services/feeds/:action',
    {action:'photos_public.gne', format: 'json', callback: 'JSON_CALLBACK'},
    {get: {method: 'JSONP'}});
$scope.flickrResult = $scope.flickr.get();

};

Any ideas how can I work around this?

  • 4
    I finally figured it out. Apparently I had to use jsoncallback instead of callback on the $resource call. That did it for me. – rafael.galante May 03 '13 at 17:34
  • You can also do this with a promise which might be a better approach. – lucuma May 04 '13 at 15:55
  • For those that are trying to get a result using raw JQuery, check this fiddle http://jsfiddle.net/Braulio/vDr36/ and this questions: http://stackoverflow.com/questions/8292050/is-there-any-publically-accessible-json-data-source-to-test-with-real-world-data/20151543#20151543 and http://stackoverflow.com/questions/13854250/understanding-cross-domain-xhr-and-xml-data – Braulio Nov 22 '13 at 18:39

0 Answers0