3

Is there a way to break aura:iteration on certain count. I know , the best way to deal this in controller and provide the right count in items, however, i have got stuck in a situation where I was looking for breaking the <aura:iteration> based on indexVar. Thanks a lot .

  • can you share your code – Santanu Boral May 14 '18 at 2:38
  • You can use aura:if and stop rendering after certain index. Not super efficient, but should work. – dzh May 18 '18 at 9:37
7

Can we not use start and end attributes to break the loop?

Here is the working sample:

<aura:component>
    <aura:iteration start="3" end="6" items="1,2,3,4,5,6,7,8,9,10" var="item">
        {!item} <br/>
    </aura:iteration>    
</aura:component>
  • Where did you find start and end attributes, they are not listed in the aura:iteration documentation. – Raul May 14 '18 at 7:22
  • +1 Nice finding! – Raul May 14 '18 at 7:49
  • 2
    If the restriction is more about content than index, you can also wrap the interior of the iteration with an aura:if so that it will only render items meeting that criteria. – Charles T May 14 '18 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.