Suppléant ligne couleurs angulaire de la table de matériaux

Je me demande comment je cible le pair/impair de lignes à l'intérieur d'un Angular Material Table afin que je puisse régler le pair/impair lignes d'une autre couleur d'arrière-plan.

- Je configurer mon ClaimFileHistoryDataSource classe:

claimClientInformation: ClaimFileHistory[];
dataSource : ClaimFileHistoryDataSource;
displayedColumns = ['TypeImg', 'Description', 'Agent'];


export class ClaimFileHistoryDataSource extends DataSource<ClaimFileHistory> {

    constructor(private _claimFileHistory: ClaimFileHistory[]) {
      super();
    }

    connect(): Observable<ClaimFileHistory[]> {
      return Observable.of(this._claimFileHistory);
    }

    disconnect() {}
}

Sur NgInit je fais un appel à mes services pour aller chercher les données dont j'ai besoin et remplir le DataSource:

this._claimFileHistoryService.getClaimFileHistoryById().subscribe(response => {
  this.claimClientInformation = response;       
  this.dataSource = new ClaimFileHistoryDataSource(this.claimClientInformation);
});

C'est très bien et les Données est de retour comme il se doit.

Dans le code HTML de la Mat-Table ressemble à ceci:

    <mat-table #table [dataSource]="dataSource">

      <ng-container matColumnDef="TypeImg">
        <mat-cell *matCellDef="let row"><img [src]='row.TypeImg' height="40px"></mat-cell>
      </ng-container>

      <ng-container matColumnDef="Description">
        <mat-cell *matCellDef="let row">
          <div>
            <span class="d-block">{{row.Description}}</span>
            <span class="d-block">{{row.Date}}</span>
          </div>

        </mat-cell>
      </ng-container>

      <ng-container matColumnDef="Agent">
        <mat-cell *matCellDef="let row"> {{row.Agent}} </mat-cell>
      </ng-container>

      <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
      <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
    </mat-table>

Encore, je me demandais comment puis-je obtenir le pair/Impair de lignes de la table, et d'une ligne différente de la couleur de fond?

OriginalL'auteur Ben Clarke | 2017-11-01