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

64
Views
Angular Switching Header According to Id

In my code, I have a screen which I use for different elements. In this screen, I have a table. I want to change one of the columns' header according to the SourceType. When I try that like I've written below, it gives an error. What should I do, use to achieve what I want?

HTML:

<ng-container matColumnDef="DeliveryNumber">
            <th mat-header-cell *matHeaderCellDef *ngIf="_stockEntry.SourceType != 49"> Tesellüm No </th>
            <th mat-header-cell *matHeaderCellDef *ngIf="_stockEntry.SourceType == 49"> Parti No </th>
            <td mat-cell *matCellDef="let row; let i = index">
                <span *ngIf="EditIndex != i">{{row.DeliveryNumber}}</span>
                <mat-form-field floatLabel="never" *ngIf="EditIndex == i" class="w-100-p">
                    <mat-select [(ngModel)]="row.DeliveryNumber" required name="DeliveryNumber">
                        <mat-option *ngFor="let prm of deliveryList" [value]="prm.DeliveryNumber">
                            {{prm.DeliveryNumber}}
                        </mat-option>
                    </mat-select>
                </mat-form-field>
            </td>
        </ng-container>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't have multiple structural directives (*ngIf & *matHeaderCellDef ) on one element. So what you can do is having ngIf on a ng-container :

<ng-container matColumnDef="DeliveryNumber">
    <th mat-header-cell *matHeaderCellDef > 
        <ng-container *ngIf="_stockEntry.SourceType !== 49">Tesellüm No </ng-container>
        <ng-container *ngIf="_stockEntry.SourceType == 49">Parti No </ng-container>
    </th>
    <td mat-cell *matCellDef="let row; let i = index">
        <span *ngIf="EditIndex != i">{{row.DeliveryNumber}}</span>
        <mat-form-field floatLabel="never" *ngIf="EditIndex == i" class="w-100-p">
            <mat-select [(ngModel)]="row.DeliveryNumber" required name="DeliveryNumber">
                <mat-option *ngFor="let prm of deliveryList" [value]="prm.DeliveryNumber">
                    {{prm.DeliveryNumber}}
                </mat-option>
            </mat-select>
        </mat-form-field>
    </td>
</ng-container>
about 4 years ago · Juan Pablo Isaza Report
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!