如何使用ng-repeat指示数组中的哪些项要显示?例如,我只想重复快照数组中的4-6个快照。
<div class="shot" ng-repeat="shot in shots">
<!-- only show shots 4-6 in the array -->
<a href="{{ shot.url }}"><img ng-src="{{ shot.thumbnail }}"></a>
</div>
发布于 2019-08-11 14:03:37
使用limitTo
过滤器:
<div class="shot" ng-repeat="shot in shots | limitTo : limit : begin">
<!-- only show shots 4-6 in the array -->
<a href="{{ shot.url }}"><img ng-src="{{ shot.thumbnail }}"></a>
</div>
$scope.limit = 6-4+1;
$scope.begin = 4;
有关详细信息,请参阅
https://stackoverflow.com/questions/57447613
复制相似问题