0

I try to read two rss feed and i have an error.

This is my ctrl and the factory :

app.factory('FeedService', ['$http', function($http){
    return {
        parseFeed : function(url) {
            return $http.jsonp('https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&callback=JSON_CALLBACK&q=' + encodeURIComponent(url));
        }
    }
}]);

app.controller('ActuCtrl', ['$scope', '$rootScope', 'FeedService', function($scope, $rootScope, Feed1, Feed2) {

        Feed1.parseFeed("https://www.facebook.com/feeds/page.php?id=618857251494402&format=rss20").then(function(res){
            $scope.feeds1=res.data.responseData.feed.entries;
        $scope.quantity1 = 5;
        });

        Feed2.parseFeed("https://www.facebook.com/feeds/page.php?id=149375131740957&format=rss20").then(function(res){
            $scope.feeds2=res.data.responseData.feed.entries;
        $scope.quantity2 = 5;
        });

}]);

my html :

    <ul>
        <li ng-repeat="feed in feeds1 | filter:cleanit | limitTo:quantity1">                    
            <p><a href="{{feed.link}}">{{feed.title}}</a></p>                                        
        </li>
    </ul>

    <ul>
        <li ng-repeat="feed2 in feeds2 | filter:cleanit | limitTo:quantity2">                    
            <p><a href="{{feed.link}}">{{feed.title}}</a></p>                                        
        </li>
    </ul>

and the error:

TypeError: Cannot read property 'parseFeed' of undefined at new (ActuCtrl.js:16:14)

What's wrong ?

3
  • What is Feed2? It will be undefined anyways you are not specifying the dependency for that Commented Aug 11, 2014 at 17:43
  • For that matter, what is Feed1? Commented Aug 11, 2014 at 17:45
  • @MikeRobinson feed1 will be FeedService instance, see the dependencies Commented Aug 11, 2014 at 17:45

1 Answer 1

1
app.controller('ActuCtrl', ['$scope', '$rootScope', 'FeedService', function($scope, $rootScope, Feed) {

    Feed.parseFeed("https://www.facebook.com/feeds/page.php?id=618857251494402&format=rss20").then(function(res) {
        $scope.feeds1 = res.data.responseData.feed.entries;
        $scope.quantity1 = 5;
    });

    Feed.parseFeed("https://www.facebook.com/feeds/page.php?id=149375131740957&format=rss20").then(function(res) {
        $scope.feeds2 = res.data.responseData.feed.entries;
        $scope.quantity2 = 5;
    });

}]);

Remove Feed2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.