Forked from daniele-zurico/ngx-data-table.component.ts
Created
April 2, 2019 17:09
-
-
Save talamaska/fffaa7c654767461b3db478688b96db2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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