angular.js - How to implement ng-repeat reverse loop?
仅有的幸福
仅有的幸福 2017-05-15 16:59:17
0
3
892

I want to loop a json array using angularjs,

<p class="gwc-p mar-t20"  ng-repeat="shopdata in cartinfo.shopList" >
</p>

But is there any way to loop the flashback?

仅有的幸福
仅有的幸福

reply all(3)
为情所困

Try this:

<p class="gwc-p mar-t20"  ng-repeat="shopdata in cartinfo.shopList.slice().reverse()" ></p>

Or declare a filter...

js:

app.filter('reverse', function() {
    return function(items) {
        return items.slice().reverse();
    };
});

view:

<p class="gwc-p mar-t20"  ng-repeat="shopdata in cartinfo.shopList | reverse" ></p>
左手右手慢动作

js itself has the reverse function reverse()

迷茫

<p class="gwc-p mar-t20" ng-repeat="shopdata in cartinfo.shopList | orderBy:shopId:reverse"></p>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template