I am trying to use a factory that I can assign to a scoped angular variable. However, whenever I attemp to attach this and use console.log to return this variable I am am returned with the function as text and not as a value. Is there a way I can get this fixed?
========== JS ==========
annApp.factory('rssFeed', function() { return function() { var events = []; $.get('xmlfile', function(xml) { var json = $.xml2json(xml); jsonb = JSON.stringify(json, undefined, 3 ); // var events = []; var description = json['#document']['rss']['channel']['item']['description']; var title = json['#document']['rss']['channel']['item']['title']; var date = json['#document']['rss']['channel']['item']['pubDate']; events.push({'title': title, 'description':description, 'date': date}); return events; }); return events; } annApp.controller('calendar', ['$scope', 'rssFeed', function($scope, rssFeed){ $scope.events = rssFeed; console.log($scope.events); }]);
console.log($scope.events());Also, I believe the line afterreturn events;should be};});