I'm trying to add multiple classes by ngClass, and I'm confused as to why I can't use ternary operator here.
<div [ngClass]="{'otherClass': otherFlag, classFlag ? 'class--true': 'class--false'}>
I get the following error:
Parser Error: Missing expected } at column 37 in [{'otherClass': otherFlag, classFlag ? 'class--true': 'class--false'}]
I'm aware I can do the following:
<div [ngClass]="{
'otherClass': otherFlag,
'class--true': classFlag,
'class--false': !classFlag
}">
Just trying to understand why I can't use ternary operator here (or maybe I'm doing it wrong). I would appreciate the help in understanding this.
Edit: Thank you for both answers. I mostly understood it thanks to Bryan's answer, but both were helpful.