Home > Net >  How can i use string interpolation in ngClass in Angular 11?
How can i use string interpolation in ngClass in Angular 11?

Time:01-29

How can achive it that the class name will be forexample "table1-RED" According to color property.It has color property.(I use not the base material table and this has color property of element.Maybe the angular-material is has also i dont know.I just wanted to say not this the problem).I have more hundred row like this and I want to make it dynamically.Angular 11.

   <table mat-table [dataSource]="dataSource" >
    
      <ng-container matColumnDef="id">
        <th mat-header-cell *matHeaderCellDef >Id</th>
        <td mat-cell *matCellDef="let element" ngClass="table1-{{element.color}}"  >{{ element.id }}</td>
      </ng-container>

CodePudding user response:

this is working for me

[ngClass]="'table1-'  element.color"

CodePudding user response:

[ngClass]="'table1-'  element.color"

or

[class]="'table1-'  element.color"
  •  Tags:  
  • Related