16

I am looping on a collection of models and want to show one element per model. However, for CSS reasons, I must add another element when I reach the forth model (I need to add a Bootstrap clearfix element for the layout to look good).

<div class="jumbotron">
    <ol class="row">
        <li *ngFor="#card of deck; #i = index" class="col-xs-3">
            <h3>{{ card.name }}</h3>
        </li>
    </ol>
</div>

How do I say if (i + 1) % 4 === 0, then add this li plus another <li class="clearfix"></li>?

David L
  • 32,885
  • 8
  • 62
  • 93
Maxime Dupré
  • 5,319
  • 7
  • 38
  • 72
  • 1
    Does it work if instead adding a new
  • you add the class to the
  • you already have? `
  • `, if it doesn't work you can use the
  • – Eric Martinez Apr 02 '16 at 16:53
  • No that doesn't work as I need both the "normal" `li` and the `clearfix` `li`, it can't be the same. But you are right, I continued my research and I think using the template form is the solution. You can either post it as an answer, or I'll post it when I get something that works. Thanks for the help! – Maxime Dupré Apr 02 '16 at 16:57