-1

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" class="mat-elevation-z8">
    
      <ng-container matColumnDef="id">
        <th mat-header-cell *matHeaderCellDef class="table__header">Id</th>
        <td mat-cell *matCellDef="let element" ngClass="table1-{{element.color}}"  >{{ element.id }}</td>
      </ng-container>

2 Answers 2

0

this is working for me

[ngClass]="'table1-'+ element.color"
Sign up to request clarification or add additional context in comments.

1 Comment

A good answer will always include an explanation why this would solve the issue, so that the OP and any future readers can learn from it.
0
[ngClass]="'table1-'+ element.color"

or

[class]="'table1-'+ element.color"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.