Answers for "angualr add class to component"

1

angualr add class to component

@Component({
   selector: 'app-your-component',
   templateUrl: './your-component.component.html',,
   host: {'class': 'your-class'}
})
export class YourComponent implements OnInit {
...
}
Posted by: Guest on January-19-2021
0

add class to element angular in 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'"
Posted by: Guest on March-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language