Skip to content

Commit 32111e0

Browse files
butterprimjosephperrott
authored andcommitted
change OnInit to AfterViewInit to load MatSort before http table request (#11122)
1 parent e59d0fb commit 32111e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/material-examples/table-http/table-http-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {HttpClient} from '@angular/common/http';
2-
import {Component, OnInit, ViewChild} from '@angular/core';
2+
import {AfterViewInit, Component, ViewChild} from '@angular/core';
33
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
44
import {merge, Observable, of as observableOf} from 'rxjs';
55
import {catchError, map, startWith, switchMap} from 'rxjs/operators';
@@ -12,7 +12,7 @@ import {catchError, map, startWith, switchMap} from 'rxjs/operators';
1212
styleUrls: ['table-http-example.css'],
1313
templateUrl: 'table-http-example.html',
1414
})
15-
export class TableHttpExample implements OnInit {
15+
export class TableHttpExample implements AfterViewInit {
1616
displayedColumns = ['created', 'state', 'number', 'title'];
1717
exampleDatabase: ExampleHttpDao | null;
1818
dataSource = new MatTableDataSource();
@@ -26,7 +26,7 @@ export class TableHttpExample implements OnInit {
2626

2727
constructor(private http: HttpClient) {}
2828

29-
ngOnInit() {
29+
ngAfterViewInit() {
3030
this.exampleDatabase = new ExampleHttpDao(this.http);
3131

3232
// If the user changes the sort order, reset back to the first page.

0 commit comments

Comments
 (0)