1
1
import { HttpClient } from '@angular/common/http' ;
2
- import { Component , OnInit , ViewChild } from '@angular/core' ;
2
+ import { AfterViewInit , Component , ViewChild } from '@angular/core' ;
3
3
import { MatPaginator , MatSort , MatTableDataSource } from '@angular/material' ;
4
4
import { merge , Observable , of as observableOf } from 'rxjs' ;
5
5
import { catchError , map , startWith , switchMap } from 'rxjs/operators' ;
@@ -12,7 +12,7 @@ import {catchError, map, startWith, switchMap} from 'rxjs/operators';
12
12
styleUrls : [ 'table-http-example.css' ] ,
13
13
templateUrl : 'table-http-example.html' ,
14
14
} )
15
- export class TableHttpExample implements OnInit {
15
+ export class TableHttpExample implements AfterViewInit {
16
16
displayedColumns = [ 'created' , 'state' , 'number' , 'title' ] ;
17
17
exampleDatabase : ExampleHttpDao | null ;
18
18
dataSource = new MatTableDataSource ( ) ;
@@ -26,7 +26,7 @@ export class TableHttpExample implements OnInit {
26
26
27
27
constructor ( private http : HttpClient ) { }
28
28
29
- ngOnInit ( ) {
29
+ ngAfterViewInit ( ) {
30
30
this . exampleDatabase = new ExampleHttpDao ( this . http ) ;
31
31
32
32
// If the user changes the sort order, reset back to the first page.
0 commit comments