0
我遇到了使用angularjs從Unsplash API獲取隨機圖像的問題。我曾嘗試使用下面的代碼示例,我發現試過,但它不工作:從使用angularjs的unsplash API獲取隨機圖像
$scope.images = function(){
$http({
method: "GET",
url: "https://api.unsplash.com/photos/?client_id=1a28e59e586593faf822eb102154d46e8f56c830d3e5d896a0293804233f991a&per_page=30&page="+$scope.pagenumber,
}).then(
function(res)
{
var totalFound=res.data.length;
console.log('totalFound',res);
var photo=[];
for(var i=0;i<totalFound;i++)
{
var full=res.data[i].urls.full;
var regular=res.data[i].urls.regular;
var raw=res.data[i].urls.raw;
var small=res.data[i].urls.small;
var thumb=res.data[i].urls.thumb;
photo.push({
full:full,
regular:regular,
raw:raw,
small:small,
thumb:thumb
});
}
$scope.photo=photo;
},
function(res)
{
console.log('error',res);
});
}
沒有結果?沒有錯誤沒有輸出什麼?你的屏幕只是空白? ...打開顯示器:)你的代碼似乎並不完整,請填寫空格,並檢查你的控制檯。 – shaunhusain