简体   繁体   English

无法在Mobile Angular Ui(Angular Js)中从JSON检索图像。

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

I want to retrieve image from JSON. 我想从JSON检索图像。 Right now i am retrieving all these things from JSON Like Price, Display order But Image can't be retrieve. 现在,我正在从JSON中检索所有这些东西,例如价格,显示顺序,但无法检索图像。

HTML: 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: 控制器:

.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){

    })
})

Right now i am retrieving data from this URL: 现在,我正在从以下URL检索数据:

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

i want to retrieve image from json. 我想从json检索图像。 Please share your ideas. 请分享您的想法。

You are not using the correct format in the reponse of the $http promise. 您在$ http承诺的响应中使用的格式不正确。 The code should be : 该代码应为:

$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