I have the following code
<div *ngFor="let item of items">
<button [disabled]="doSomething(item)"></button>
<input [someProperty]="doSomething(item)"></div>
<div [ngClass]="{
'class1': item.attr == 'val1' || doSomething(item),
'class2': row.attr != 'val2' && !doSomething(item)
}"
></div>
in component
doSomething(item) {
return someBooleanLogic(item);
}
I feel it is not a good practice to recalculate every time the doSomething value for each item in the template.
Is there a more recommended way to do this?