Skip to content

Instantly share code, notes, and snippets.

@abelorian
Created September 29, 2014 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abelorian/25a85e54e8075978c86c to your computer and use it in GitHub Desktop.
Save abelorian/25a85e54e8075978c86c to your computer and use it in GitHub Desktop.
RSS con AngularJS y Google Feader API
var feeds = [];
angular.module('feedModule', ['ngResource'])
.factory('FeedLoader', function ($resource) {
return $resource('http://ajax.googleapis.com/ajax/services/feed/load', {}, {
fetch: { method: 'JSONP', params: {v: '1.0', callback: 'JSON_CALLBACK'} }
});
})
.service('FeedList', function ($rootScope, FeedLoader) {
this.get = function() {
var feedSources = [
{title: 'Bta', url: 'http://backtrackacademy.com/feed/'}
];
if (feeds.length === 0) {
for (var i=0; i<feedSources.length; i++) {
FeedLoader.fetch({q: feedSources[i].url, num: 10}, {}, function (data) {
var feed = data.responseData.feed;
feeds.push(feed);
});
}
}
return feeds;
};
})
.controller('FeedCtrl', function ($scope, FeedList) {
$scope.feeds = FeedList.get();
$scope.$on('FeedList', function (event, data) {
$scope.feeds = data;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment