我尝试使用工厂重写我的代码:
我目前的代码:
$http({ method: "JSONP", url: url}).success(function(data){
$scope.albums = data.entries;
});
没问题
但是我的新代码:
app.factory('Album', ['$resource', function ($resource) {
return $resource(url, {}, {query: {method: 'JSONP', params: {}}});
}]);
...
$scope.albums = Album.get();
...
返回
XMLHttpRequest cannot load http://api-fotki.yandex.ru/api/users/ru-proton/albums/?format=json&callback=JSON_CALLBACK. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
我做错了什么?