From 32111e0dc6e6fc9de848c99499ad2858cf12cd9c Mon Sep 17 00:00:00 2001 From: Lizette Date: Fri, 4 May 2018 05:14:22 +0800 Subject: [PATCH] change OnInit to AfterViewInit to load MatSort before http table request (#11122) --- src/material-examples/table-http/table-http-example.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/material-examples/table-http/table-http-example.ts b/src/material-examples/table-http/table-http-example.ts index a242d732fc2..f3aee68d1ed 100644 --- a/src/material-examples/table-http/table-http-example.ts +++ b/src/material-examples/table-http/table-http-example.ts @@ -1,5 +1,5 @@ import {HttpClient} from '@angular/common/http'; -import {Component, OnInit, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, ViewChild} from '@angular/core'; import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material'; import {merge, Observable, of as observableOf} from 'rxjs'; import {catchError, map, startWith, switchMap} from 'rxjs/operators'; @@ -12,7 +12,7 @@ import {catchError, map, startWith, switchMap} from 'rxjs/operators'; styleUrls: ['table-http-example.css'], templateUrl: 'table-http-example.html', }) -export class TableHttpExample implements OnInit { +export class TableHttpExample implements AfterViewInit { displayedColumns = ['created', 'state', 'number', 'title']; exampleDatabase: ExampleHttpDao | null; dataSource = new MatTableDataSource(); @@ -26,7 +26,7 @@ export class TableHttpExample implements OnInit { constructor(private http: HttpClient) {} - ngOnInit() { + ngAfterViewInit() { this.exampleDatabase = new ExampleHttpDao(this.http); // If the user changes the sort order, reset back to the first page.