Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs ng重复更多数据_Javascript_Html_Angularjs - Fatal编程技术网

Javascript Angularjs ng重复更多数据

Javascript Angularjs ng重复更多数据,javascript,html,angularjs,Javascript,Html,Angularjs,js应用程序 现在在html中,我重复一次 <div class="row"> <div ng-repeat="item in Photos" class="col col-33"style="border:none"> <img ng-src="{{item.image}}" imageonload style="width:100px;height:120px;margin-left:auto;margin-right:auto;display:blo

js应用程序

现在在html中,我重复一次

<div class="row">
 <div ng-repeat="item in Photos" class="col col-33"style="border:none">
    <img ng-src="{{item.image}}" imageonload style="width:100px;height:120px;margin-left:auto;margin-right:auto;display:block">
  </div>
</div>

我的问题是,我在列表中有5张图片,但其中只有3张在dipslay上。另一个2未显示在显示屏上。我怎样才能解决这个问题


提前感谢

可能是您的图像在
照片
数组中具有相同的url值,因此您需要像这样使用
ng repeat
track by$index

<div class="row">
 <div ng-repeat="item in Photos track by $index" class="col col-33"style="border:none">
    <img ng-src="{{item.image}}" imageonload style="width:100px;height:120px;margin-left:auto;margin-right:auto;display:block">
  </div>
</div>

尝试
col-xs-2
而不是
col-33

<div class="row">
  <div ng-repeat="item in Photos" class="col col-xs-2">
    <img ng-src="{{item.image}}">
  </div>
</div>

$scope.imagearray={
“图像”:[]
};
变量i,j,temparray,chunk=3;

对于(i=0,j=$scope.Photos.length;i显示您的json,请包括您的json。这可能会有帮助。好的,然后您可以从控制器中控制台记录$scope.Photos,并检查是否有5个数据。这给出了5个数据,但所有这些数据都很接近。我希望它在每3个图像之后再行。好的,所以问题不是获取5个图像,而是获取三合一行和下两个在另一行中。这不能在单个重复中实现,您需要将其分成两个数组,并使用javascript使用两个ng重复。$scope.imagearray={'images':[]};var i,j,temparray,chunk=3;for(i=0,j=$scope.Photos.length;i
$scope.imagearray = {
       'images' : []
  };
 var i,j,temparray,chunk = 3;
 for (i=0,j=$scope. Photos.length; i<j; i+=chunk) {
   temparray = $scope. Photos.slice(i,i+chunk);
        $scope.imagearray.images.push(temparray);
  }

    <div  ng-repeat="img in imagearray.images">
        <span ng-repeat="item in img" ></span>
        </div>