Quantcast
Browsing all 26 articles
Browse latest View live

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 Article


Answer 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 Article


Answer 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 Article

Answer 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 Article

Angular: 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 Article


Answer 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
Browsing all 26 articles
Browse latest View live