[SalesForce] Salesforce solution to Filter or Limit Aura iteration

I am iterating through a list of items as follows

<aura:iteration items="{!v.objWrap}" var="item" indexVar="idx">
...
...
...
 </aura:iteration>

I also want to have a load more button after this that shows an additional 10 items.

<a href="javascript:void(0); onclick="myfunction()"">Load More</a>

Is it possible to filter the iteration to show a set amount, then when I click the load more, it loads another 10? Is there a way through salesforce that would make this easier?

Thanks

Best Answer

You simply use aura:if and check if you indexVar is smaller or equals 10. I think it should look something like this.

<aura:iteration items="{!v.objWrap}" var="item" indexVar="idx">
    <aura:if value="{!idx < 10}">
        <a href="javascript:void(0); onclick="otherfunction()"">{!item.Something__c}</a>
    </aura:if>
    <aura:if value="{!idx == 10}">
        <a href="javascript:void(0); onclick="myfunction()"">Load More</a>
    </aura:if>
</aura:iteration>
Related Topic