簡體   English   中英

無法在Mobile Angular Ui(Angular Js)中從JSON檢索圖像。

[英]Not retrieve image from JSON in Mobile Angular Ui.(Angular Js)

我想從JSON檢索圖像。 現在,我正在從JSON中檢索所有這些東西,例如價格,顯示順序,但無法檢索圖像。

HTML:

<div ng-controller="chooseProductDescription">
                <div ng-repeat="cat in productDescription">
                        <img src="{{cat.product.productPictures[0].pictureUrl}}">
                        <span>Price</span>{{cat.product.price}}
                        <span>Display Order</span>{{cat.product.productPictures[0].displayOrder}}
                </div>
            </div>

控制器:

.controller('chooseProductDescription', function($scope, $http){
    $http({
        method:'get',
        url:'http://www.json-generator.com/api/json/get/cgrvadFrGW?indent=2',
        header:{'Content-Type':'application/json'},
    }).success(function(data,status,headers, config){   
        $scope.productDescription = data;
        alert("shjkshjksadhkjas");
    }).error(function(data, status,headers, config){

    })
})

現在,我正在從以下URL檢索數據:

http://www.json-generator.com/api/json/get/cgrvadFrGW?indent=2

我想從json檢索圖像。 請分享您的想法。

您在$ http承諾的響應中使用的格式不正確。 該代碼應為:

$http({
    method:'get',
    url:'http://www.json-generator.com/api/json/get/cgrvadFrGW?indent=2',
    header:{'Content-Type':'application/json'},
}).success(function(response){   
    $scope.productDescription = response.data;
    alert("shjkshjksadhkjas");
}).error(function(response){

})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM