import { Component } from '@angular/core' ; import { INglDatatableSort , INglDatatableRowClick } from 'ng-lightning' ; const DATA = [ { rank : 1 , name : 'Kareem' , surname : 'Abdul-Jabbar' , points : 38387 } , { rank : 2 , name : 'Karl' , surname : 'Malone' , points : 36928 } , { rank : 3 , name : 'Kobe' , surname : 'Bryant' , points : 33643 } , { rank : 4 , name : 'Michael' , surname : 'Jordan' , points : 32292 } , { rank : 5 , name : 'Wilt' , surname : 'Chamberlain' , points : 31419 } , ] ; @ Component ( { selector : 'app-demo-datatables-basic' , templateUrl : './basic.html' , } ) export class DemoDatatablesBasic { data = DATA ; sort : INglDatatableSort = { key : 'rank' , order : 'asc' } ; loading = false ; hideName = false ; onSort ( $event ) { const { key , order } = $event ; this . data . sort ( ( a , b ) => { return ( key === 'rank' ? b [ key ] - a [ key ] : b [ key ] . localeCompare ( a [ key ] ) ) * ( order === 'desc' ? 1 : - 1 ) ; } ) ; } toggleData ( ) { this . data = this . data ? null : DATA ; } onRowClick ( $event ) { console . log ( 'clicked row' , $event . data ) ; } }