添加类件使用指令的角度

代码示例

0
0

添加类元素在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'"
0
0

创建CSS类指令的角度

@Directive({
    selector: '[myHighlight]',
})
class MyDirective {
  @HostBinding('style.background-color')
  backgroundColor:string = 'yellow';
}

类似页面

带有示例的类似页面

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................