由网友(习惯习惯就好)分享简介:我想要实现的布局是这样的: < DIV> < DIV CLASS =行> < DIV>< / DIV> < DIV>< / DIV> < / DIV> < DIV...![15ppm舱底油污水分离器0.5m3 h新标准CCS船检 油污水处理器,油水分离器,舱底水分离器,船用油水分离器](/d/file/2023/09-17/f4990353d33922f3a04fc4b4f56f21f0.png)
我想要实现的布局是这样的:
< DIV> < DIV CLASS =行> < DIV>< / DIV> < DIV>< / DIV> < / DIV> < DIV CLASS =行> < DIV>< / DIV> < DIV>< / DIV> < / DIV> < DIV CLASS =行> < DIV>< / DIV> < DIV>< / DIV> < / DIV>< / DIV>
这样做让我的div,但我怎么能每两个项目之间添加分隔符?我觉得像角应该有一个简单的方法来做到这一点。
< DIV> < DIV CLASS =行> < DIV NG重复=,在对象的对象>< / DIV> < / DIV>< / DIV>
解决方案
我想,你可以用一点JavaScript和它解决了NG-重复像
< DIV> < DIV CLASS =行NG-重复=数组中OBJ2> < DIV NG重复=对象数组> {{对象}}< / DIV> < / DIV>< / DIV>
![15ppm舱底油污水分离器0.5m3 h新标准CCS船检 油污水处理器,油水分离器,舱底水分离器,船用油水分离器](/d/file/2023/09-17/f4990353d33922f3a04fc4b4f56f21f0.png)
然后在您的角度控制器创建像
称为OBJ2使用对象数组的新对象 $ scope.obj2 = [];而($ scope.objects.length){ $ scope.obj2.push($ scope.objects.splice(0,2))}
演示:小提琴
The layout I'm trying to achieve is this:
<div>
<div class="row">
<div></div>
<div></div>
</div>
<div class="row">
<div></div>
<div></div>
</div>
<div class="row">
<div></div>
<div></div>
</div>
</div>
Doing this gets me the divs, but how can I add separators between every two items? I feel like Angular should have an easy way to do this.
<div>
<div class="row">
<div ng-repeat="object in objects"></div>
</div>
</div>
解决方案
I think, you can solve it using a bit of javascript and ng-repeat like
<div>
<div class="row" ng-repeat="array in obj2">
<div ng-repeat="object in array">{{object}}</div>
</div>
</div>
then in your angular controller create a new object called obj2 using the objects array like
$scope.obj2 = [];
while ($scope.objects.length) {
$scope.obj2.push($scope.objects.splice(0, 2))
}
Demo: Fiddle
相关推荐
最新文章