import { Component , OnDestroy , OnInit } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Subject } from 'rxjs' ; import { Person } from '../person' ; @ Component ( { selector : 'app-angular-way' , templateUrl : 'angular-way.component.html' } ) export class AngularWayComponent implements OnDestroy , OnInit { pageTitle = 'Angular way' ; mdIntro = 'assets/docs/basic/angular-way/intro.md' ; mdHTML = 'assets/docs/basic/angular-way/source-html.md' ; mdTS = 'assets/docs/basic/angular-way/source-ts.md' ; dtOptions : DataTables . Settings = { } ; persons : Person [ ] = [ ] ; dtTrigger : Subject < any > = new Subject < any > ( ) ; constructor ( private httpClient ) { } ngOnInit ( ) { this . dtOptions = { pagingType : 'full_numbers' , pageLength : 2 } ; this . httpClient . get < Person [ ] > ( 'data/data.json' ) . subscribe ( data => { this . persons = ( data as any ) . data ; this . dtTrigger . next ( null ) ; } ) ; } ngOnDestroy ( ) { this . dtTrigger . unsubscribe ( ) ; } }