Created
May 22, 2018 18:29
-
-
Save daniele-zurico/c38f0c9f56ba53e4753d2c84737da101 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