@nghacks/ngmat-table-query-reflector
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

NgMatTableQueryReflector

Stores and retrieves mat table states (sorting, pagination) with url query params

Demo

Demo gif

Live Preview

How to use

Install package

npm install @nghacks/ngmat-table-query-reflector

Import NgmatTableQueryReflectorModule to your consumer module.

import { NgModule } from '@angular/core';
...
...
import { NgmatTableQueryReflectorModule } from '@nghacks/ngmat-table-query-reflector';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    NgmatTableQueryReflectorModule
  ]
})
export class ConsumerModule { }

Add directive to html template

<table
  mat-table
  [dataSource]="dataSource"
  matSort
  matSortActive="name"
  matSortDirection="desc"
  NgMatTableQueryReflector
>
  <!-- Position Column -->
  <ng-container matColumnDef="position">
    <th mat-header-cell *matHeaderCellDef mat-sort-header>No.</th>
    <td mat-cell *matCellDef="let element">{{element.position}}</td>
  </ng-container>

  <!-- Name Column -->
  <ng-container matColumnDef="name">
    <th mat-header-cell *matHeaderCellDef mat-sort-header>Name</th>
    <td mat-cell *matCellDef="let element">{{element.name}}</td>
  </ng-container>

  ... ...

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

Package Sidebar

Install

npm i @nghacks/ngmat-table-query-reflector

Weekly Downloads

2

Version

0.1.3

License

none

Unpacked Size

124 kB

Total Files

17

Last publish

Collaborators

  • abdunnahid