I want to give conditional class a div. But my problem is, I want "myClassCondition" as a string like below. When I write like this <div [class]="7 > 6 ? 'bg-red' : null"> MyText </div>
, it is working perfectly. But I want send from .ts
file as variable like below. How can I do this?
<div [class]="myClassCondition"> MyText </div>
-
myClassCondition = "7 > 6 ? 'bg-red' : null";