Suppose I have some objects in an array (the "items" array is called), for example { title: "Title", value: true }, and I use ngFor to display them, for example:
<h1 *ngFor="let item of items">{{ item.title }}</h1>
Now let's say that I want to map the class to h1 based on if item.value true or false. How can i do this?
I can not add [class.some-class]="{{ item.value }}". Basically, how can I get a true or false value for the current element in something like ngClass? Am I missing an obvious way to do this in Angular 2?
(Btw, I know I can do this by adding class="{{ item.value | pipe }}"to h1 and passing the value and returning the correct class based on the values โโof true and false, but it seems like there should be a better way.)
thank
source
share