Angular 17: Sort Material Table with Signal data source

Discussão em 'Angular' iniciado por LeO, Março 3, 2025.

  1. LeO

    LeO Guest

    I have as datasource in a Material table a signal.

    dataSource: WritableSignal<PeriodicElement[]> = signal([]);


    The data of the table is displayed properly

    I add according to the description the matSort to the header.

    <table mat-table matSort [dataSource]="dataSource()" class="mat-elevation-z8">
    <!-- Position Column -->
    <ng-container matColumnDef="position">
    <th mat-header-cell mat-sort-header *matHeaderCellDef>No.</th>
    ...


    But somehow this won't work. I've seen and tried without Signals and this worked. Any idea how to use it properly with Signals?

    Stackblitz

    Continue reading...

Compartilhe esta Página