Quantcast
Channel: Angular: conditional class with *ngClass - Stack Overflow
Viewing all articles
Browse latest Browse all 26

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

$
0
0

Additionally, you can add with method function:

In HTML

<div [ngClass]="setClasses()">...</div>

In component.ts

// Set Dynamic Classes  setClasses() {    let classes = {      constantClass: true,'conditional-class': this.item.id === 1    }    return classes;  }

Viewing all articles
Browse latest Browse all 26

Trending Articles



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