I have some CSS classes that can have multiple names, how do I pass these names to ngClass?
The following is an example that doesn't work. How do I pass itemName
to ngClass
?
<div [ngClass]="isItem ? 'item {{itemName}}' : 'noItem {{itemName}}'"> </div>
P粉6270270312023-09-15 00:35:19
Template interpolation is not possible inside the [ngClass]
directive, just remove the brackets and concatenate the variable with the string.
<div [ngClass]="isItem ? 'item '+itemName : 'noItem'+itemName"></div>