Answer by MostafaMashayekhi for Angular: conditional class with *ngClass
Angular version 2+ provides several ways to add classes conditionally:type one [class.my_class] = "step === 'step1'"type two [ngClass]="{'my_class': step === 'step1'}"and multiple option:...
View ArticleAnswer by Joel Almeida for Angular: conditional class with *ngClass
Another solution would be using [class.active].Example :<ol class="breadcrumb"><li [class.active]="step=='step1'" (click)="step='step1'">Step1</li></ol>
View ArticleAnswer by Thierry Templier for Angular: conditional class with *ngClass
You should use something ([ngClass] instead of *ngClass) like that:<ol class="breadcrumb"><li [ngClass]="{active: step==='step1'}" (click)="step='step1; '">Step1</li> (...)
View ArticleAnswer by Günter Zöchbauer for Angular: conditional class with *ngClass
[ngClass]=... instead of *ngClass.* is only for the shorthand syntax for structural directives where you can for example use<div *ngFor="let item of items">{{item}}</div>instead of the...
View ArticleAngular: conditional class with *ngClass
What is wrong with my Angular code? I am getting the following error:Cannot read property 'remove' of undefined at BrowserDomAdapter.removeClass<ol><li *ngClass="{active: step==='step1'}"...
View ArticleAnswer by OMANSAK for Angular: conditional class with *ngClass
Some usefull helper pipes for ngClass@Pipe({ name: 'condition'})export class ONgConditionPipe implements PipeTransform { transform(value: any, condition?: any): any { if (condition != null) { return...
View Article