Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Angular mat-table displaying repeat rows

I am trying to create a relatively simple mat-table that displays elements from a "dataSource". My problem is that when I run my code it gives me the error: There can only be one default row without a when predicate function. Adding multiTemplateDataRows to my <mat-table> fixes this problem but makes it so that all of the elements in my table are duplicated (two of them). Picture displaying duplication I want to understand why is is happening. I believe that in my case the items are duplicated because I have exactly two columns. Can someone help me understand? My Code: HTML:

<mat-table [dataSource]="siteContacts" multiTemplateDataRows class="table" fxLayout="column wrap">
      <ng-container [matColumnDef]="col" *ngFor="let col of siteContactColumns">
        <mat-header-cell *matHeaderCellDef>
        </mat-header-cell>
        <mat-cell *matCellDef="let element">
          <div [ngSwitch]="siteContactDataSchema[col]">
            <div *ngSwitchCase="'ContactTitle'">
              {{element[col]}}
            </div>
            <span *ngSwitchDefault>
              {{element[siteContactDataSchema[col][0]]}} <br>
              {{element[siteContactDataSchema[col][1]]}} <br>
              {{element[siteContactDataSchema[col][2]]}}
            </span>
          </div>
        </mat-cell>
        <mat-row *matRowDef="let row; let even = even; columns: siteContactColumns;" [ngClass]="{gray: even}">
        </mat-row>
      </ng-container>

    </mat-table>

Typescript:

const SITE_CONTACTS_SCHEMA = {
  "ContactTitle": "ContactTitle",
  "ContactInfo": ["ContactName", "ContactCellPhone", "ContactEmail"]
}
...
  siteContactDataSchema = SITE_CONTACTS_SCHEMA;
  siteContactColumns: string[] = ['ContactTitle', 'ContactInfo'];
...
this.siteDirectoryService.getAllSiteContacts(this.parentSiteId).subscribe(res => {
      this.siteContacts = res;
    })
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!