เพิ่มชั้นเรียนต้องธาตุสี่เหลี่ยมใน ts
type one
[class.my-class]="step === 'step1'"
type two
[ngClass]="{'my-class': step === 'step1'}"
and multiple option:
[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'"
สร้าง CSS ชั้นเรียนอยู่ในต้องทำตามคำสั่งสี่เหลี่ยม
@Directive({
selector: '[myHighlight]',
})
class MyDirective {
@HostBinding('style.background-color')
backgroundColor:string = 'yellow';
}