Quantcast
Channel: Angular: conditional class with *ngClass - Stack Overflow
Browsing all 25 articles
Browse latest View live

Answer by umutyerebakmaz for Angular: conditional class with *ngClass

The example is a bit big, but triggering a class instead of typing inline is my first preferred approach.this way you can add as many possibilities as you want to your element.There may be a way for...

View Article



Answer by Priyanka Ahire for Angular: conditional class with *ngClass

If user want to display the class on basis of && and ||then below one is work for me[ngClass]="{'clasname_1': condition_1 && condition_2, 'classname_2': condition_1 &&...

View Article

Answer by Tharindu Lakshan for Angular: conditional class with *ngClass

The directive operates in three different ways, depending on which of three types the expression evaluates to:If the expression evaluates to a string, the string should be one or more space-delimited...

View Article

Answer by Naeem Bashir for Angular: conditional class with *ngClass

Angular provides multiple ways to add classes conditionally:First wayactive is your class name[class.active]="step === 'step1'"Second wayactive is your class name[ngClass]="{'active':...

View Article

Answer by Halil İbrahim Oymacı for Angular: conditional class with *ngClass

For elseif statement (less comparison) use like that: (For example you compare three statement)<div [ngClass]="step === 'step1' ? 'class1' : (step === 'step2' ? 'class2' : 'class3')"> {{step}}...

View Article


Answer by Sunny for Angular: conditional class with *ngClass

We can make class dynamic by using following syntax. In Angular 2 plus, you can do this in various ways:[ngClass]="{'active': arrayData.length &&...

View Article

Answer by Aishwarya Kathavarayan for Angular: conditional class with *ngClass

Try Like this..Define your class with ''<ol class="breadcrumb"><li *ngClass="{'active': step==='step1'}" (click)="step='step1; '">Step1</li><li *ngClass="{'active':...

View Article

Answer by Waleed Shahzaib for Angular: conditional class with *ngClass

You can use [ngClass] or [class.classname], both will work the same.[class.my-class]="step==='step1'"   OR[ngClass]="{'my-class': step=='step1'}"Both will work the same!

View Article


Answer by amarbhanu for Angular: conditional class with *ngClass

<div class="collapse in " [ngClass]="(active_tab=='assignservice' || active_tab=='manage')?'show':''" id="collapseExampleOrganization" aria-expanded="true" style=""><ul> <li...

View Article


Answer by Alper BULUT for Angular: conditional class with *ngClass

Additionally, you can add with method function:In HTML<div [ngClass]="setClasses()">...</div>In component.ts// Set Dynamic Classes setClasses() { let classes = { constantClass:...

View Article

Answer by Hamza Khanzada for Angular: conditional class with *ngClass

Not relevant with [ngClass] directive but I was also getting the same error asCannot read property 'remove' of undefined at...and I thought to be the error in my [ngClass] condition but it turned out...

View Article

Answer by Chirag for Angular: conditional class with *ngClass

ngClass syntax:[ngClass]="{'classname' : conditionFlag}"You can use like this: <ol class="breadcrumb"><li [ngClass]="{'active': step==='step1'}"...

View Article

Answer by Abdus Salam Azad for Angular: conditional class with *ngClass

Let, YourCondition is your condition or a boolean property, then do like this[class.yourClass]="YourCondition"

View Article


Answer by Rohit.007 for Angular: conditional class with *ngClass

In Angular 7.XThe CSS classes are updated as follows, depending on the type of the expression evaluation:string - the CSS classes listed in the string (space delimited) are addedArray - the CSS classes...

View Article

Answer by Chaitanya Nekkalapudi for Angular: conditional class with *ngClass

with the following examples you can use 'IF ELSE'<p class="{{condition ? 'checkedClass' : 'uncheckedClass'}}"><p [ngClass]="condition ? 'checkedClass' : 'uncheckedClass'"><p...

View Article


Answer by Robert Leeuwerink for Angular: conditional class with *ngClass

to extend MostafaMashayekhi his answer for option two>you can also chain multiple options with a ','[ngClass]="{'my-class': step=='step1', 'my-class2':step=='step2' }"Also *ngIf can be used in some...

View Article

Answer by Ninad Kulkarni for Angular: conditional class with *ngClass

This is what worked for me:[ngClass]="{'active': dashboardComponent.selected_menu == 'profile'}"

View Article


Answer by Sarvar Nishonboyev for Angular: conditional class with *ngClass

While I was creating a reactive form, I had to assign 2 types of class on the button. This is how I did it:<button type="submit" class="btn"...

View Article

Answer by Jameel Moideen for Angular: conditional class with *ngClass

You can use ngClass to apply the class name both conditionally and not in AngularFor Example [ngClass]="'someClass'">Conditional[ngClass]="{'someClass': property1.isValid}">Multiple Condition...

View Article

Answer by Alireza for Angular: conditional class with *ngClass

That's the normal structure for ngClass is:[ngClass]="{'classname' : condition}"So in your case, just use it like this...<ol class="breadcrumb"><li [ngClass]="{'active': step==='step1'}"...

View Article
Browsing all 25 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>