Ionic:为什么我的图像没有从我的 json 文件加载?

Ionic: Why are my images not loading from my json file?

我正在尝试将我的 json 文件中的图像加载到我的应用程序中,但我无法让它工作:

这是我的代码:

js:

.controller('photoCtrl', function($scope, $ionicModal, $ionicBackdrop, $ionicScrollDelegate, $ionicSlideBoxDelegate, $http) {
   $scope.images = [];

    $scope.getImages = function() {
        $http.get('https://api.myjson.com/bins/37ia6')
            .success(function(data) {
                $scope.images = data.images;
            })
    }

html:

<ion-view view-title="Gallery" align-title="center" ng-controller="photoCtrl" >

  <ion-content ng-init="getImages()" class="center" class="has-header padding">

    <!-- start Under6/7/8/9s Photos -->
    <div class="item item-divider">
      <i class="ion-images"></i> Under6/7/8/9s Photos
    </div>
    <a class="item item-list-detail">
      <ion-scroll direction="x">
        <img on-hold="onHold()" ng-repeat="image in images" ng-src="{{images.src}}" ng-click="showImages($index)" class="image-list-thumb" />
      </ion-scroll>
    </a>
</ion-content>
</ion-view>

试试这个:

<ion-scroll direction="x" ng-repeat="image in images"> 
  <img on-hold="onHold()" ng-src="{{image.src}}" ng-click="showImages($index)" class="image-list-thumb" /> 
</ion-scroll>

我想原因就在你的JSON。迭代时你期望发生什么:

{"images":"http://cdn.caughtoffside.com/wp-content/uploads/2012/07/Marko-Marin.jpg"}

可能您的 API 应该 return 对象数组,例如

[{"src":"http://cdn.caughtoffside.com/.../Marko-Marin.jpg"},
 {"src":"http://cdn.caughtoffside.com/.../Johnny-Blue.jpg"},
 ...
]

遍历一个对象通常看起来不一样:

<div ng-repeat="(key, value) in myObj">