I would like a class set once when the template initializes. A colleague wrote
<div [attr.class]="localVariable === 'string' ? 'class-name' : null"><div>
but this seems odd. I think I wouldn't want
[ngClass]="{'class-name': localVariable === 'string'}"
because this would run every life cycle, and I don't expect the localVariable to change dynamically during the application execution.
I prefer instead:
class="{{localVariable === 'string' ? 'class-name' : null}}"
but my colleague said that this is not advised by Angular, and that support for interpolation on attribute will be deprecated. Can anyone confirm this or make a case for which is these most performant given that the bound value is not expected to change after the template renders?