Knockout alternate formattting

I was using KnockoutJS to loop through and display some data. I wanted to apply some alternate formatting on every other row. I used this syntax containing the MOD operation to achieve the formatting I wanted.

<!-- ko if: $index() % 2 === 0 -->

The other thing I learned was that $index() is observable, so I can +1 it? I believe that is right.

The following were some sources that clued me in:!msg/knockoutjs/ElVix0ksXh8/awkTFYewitAJ


Comments are closed.

Powered by WordPress. Designed by WooThemes