In my AngularJS application, I have a piece of code that I'm using in a table. I want to apply the 'rare' class only to rows with an index of 0, 1, or 2. In other words, I want to highlight the first three rows differently from the rest.
Currently, I have the following code snippet:
ng-class="{rare : $index === 0, rare : $index === 1, rare : $index === 2}"
However, I'm wondering if there is a simpler or more concise way to achieve this. Is my current solution considered good practice? Although it works, I find the syntax a bit cumbersome. How would you approach writing the conditional checks in a clearer manner?
I attempted the following alternative:
ng-class="{rare : $index === {0,1,2}}
, but unfortunately, it did not work as expected.