Angular 2, .., 7 provides several ways to conditionally add classes:
enter one
[class.my-class]="step=='step1'"
type two
[ngClass]="{'my-class': step=='step1'}"
and several options:
[ngClass]="{'my-class': step=='step1', 'my-class2':step=='step2' }"
type three
[ngClass]="{1:'my-class1',2:'my-class2',3:'my-class4'}[step]"
type four
[ngClass]="(step=='step1')?'my-class1':'my-class2'"
MostafaMashayekhi Feb 01 '17 at 7:50 2017-02-01 07:50
source share