import { Component , OnInit } from "@angular/core" ; import { Http } from "@angular/http" ; @ Component ( { selector : 'app' , templateUrl : 'app/app.component.html' } ) export class AppComponent implements OnInit { public data : any [ ] ; public filterQuery = "" ; public rowsOnPage = 10 ; public sortBy = "email" ; public sortOrder = "asc" ; constructor ( private http ) { } ngOnInit ( ) { this . http . get ( "/app/data.json" ) . subscribe ( ( data ) => { setTimeout ( ( ) => { this . data = data . json ( ) ; } , 2000 ) ; } ) ; } public toInt ( num ) { return + num ; } public sortByWordLength = ( a ) => { return a . city . length ; } ; public remove ( item ) { let index = this . data . indexOf ( item ) ; if ( index > - 1 ) { this . data . splice ( index , 1 ) ; } } }