Is there any clean way to iterate over an array of articles in a way described below?
I have an array of articles which i want to print in rows. Each row should contain 3 articles, so the template should be something like:
<row>
<article id=1></article>
<article id=2></article>
<article id=3></article>
</row>
<row>
<article id=4></article>
<article id=5></article>
<article id=6></article>
</row>
Easiest solution I made up now would be:
- Calculate the length of array with articles, divide it by 3, get the number of rows
- Create an array with integers from 0 to calculated number
- In the template create a
<row></row>withngForover the array of integers - Inside each row create another
ngForcontaining articles with ngIf over the index of outer loop and some funky condition.
Is there any other way to nicely print out such case in Angular2?