0

我在 Chrome 中收到一条错误消息,说 Error fetching feed: Undefined, 0. 有什么建议吗?

我的角度代码是:

        // Begin SimpleController, with data
        demoApp.controller('SimpleController', function($scope, $http){
            var url = "http://www.grabapper.com/api/v1/iosapps.json";

            $http.jsonp(url).
                success(function(data,status,headers,config){
                    $scope.feed = {
                        title: 'DailyJS',
                        items: data
                    };
                }).
                error (function(data,status,headers,config){
                    console.error('Error fetching feed:', data,status);
                });

        });
        // End SimpleController

all.html:

<li ng-repeat="item in feed.items">

            {{item.name}}

    </li>
4

1 回答 1

0

Because you are calling cross domain API in your client code. You may checkout this solution.

Here is the code snippet which might shed some light on

$http.defaults.useXDomain = true;
var data =$resource(url);
if(data){
    $scope.feed = {
        title: 'DailyJS',
        items: data
    };
}else{
    console.error('Error fetching feed:', data);
};
于 2013-07-26T05:22:37.927 回答