Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talamaska/fffaa7c654767461b3db478688b96db2 to your computer and use it in GitHub Desktop.
Save talamaska/fffaa7c654767461b3db478688b96db2 to your computer and use it in GitHub Desktop.
import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { MatPaginator, MatSort } from '@angular/material';
import { NgxDataTableDataSource } from './ngx-data-table-datasource';
@Component({
selector: 'ngx-data-table',
templateUrl: './ngx-data-table.component.html',
styleUrls: ['./ngx-data-table.component.css']
})
export class NgxDataTableComponent {
@Input() set data(_data: any[]) {
this.dataSource = new NgxDataTableDataSource(this.paginator, _data, this.sort);
this.displayedColumns = Object.keys(_data[0]);
}
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
dataSource: NgxDataTableDataSource;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns: Array<string>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment