Friday, December 11, 2015

Aurelia - repeat like a for loop

It's a small thing, and it's even in the documentation, but I didn't notice it, and ended up asking on the channel and having Rob himself answer. I wanted to repeat a block, not based on item in an array, but just a fixed number of times.

Turns out, you can write:

    <li repeat.for="index of 10">${index}</li>

or

    <li repeat.for="index of itemCount">${index}</li>

and the contents are repeated the number of times indicated in the loop count.

Pretty cool.

1 comment:

Jared said...

I had no idea that was possible. Nice!