Skip to content

docs(table): incorrect initial request in http example #14692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/material-examples/table-http/table-http-example.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Structure */
.example-container {
position: relative;
min-height: 200px;
}

.example-table-container {
Expand Down
2 changes: 1 addition & 1 deletion src/material-examples/table-http/table-http-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="example-table-container">

<table mat-table [dataSource]="data" class="example-table"
matSort matSortActive="created" matSortDisableClear matSortDirection="asc">
matSort matSortActive="created" matSortDisableClear matSortDirection="desc">
<!-- Number Column -->
<ng-container matColumnDef="number">
<th mat-header-cell *matHeaderCellDef>#</th>
Expand Down
12 changes: 6 additions & 6 deletions src/material-examples/table-http/table-http-example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HttpClient} from '@angular/common/http';
import {Component, OnInit, ViewChild} from '@angular/core';
import {Component, ViewChild, AfterViewInit} from '@angular/core';
import {MatPaginator, MatSort} from '@angular/material';
import {merge, Observable, of as observableOf} from 'rxjs';
import {catchError, map, startWith, switchMap} from 'rxjs/operators';
Expand All @@ -12,9 +12,9 @@ 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: string[] = ['created', 'state', 'number', 'title'];
exampleDatabase: ExampleHttpDao | null;
exampleDatabase: ExampleHttpDatabase | null;
data: GithubIssue[] = [];

resultsLength = 0;
Expand All @@ -26,8 +26,8 @@ export class TableHttpExample implements OnInit {

constructor(private http: HttpClient) {}

ngOnInit() {
this.exampleDatabase = new ExampleHttpDao(this.http);
ngAfterViewInit() {
this.exampleDatabase = new ExampleHttpDatabase(this.http);

// If the user changes the sort order, reset back to the first page.
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
Expand Down Expand Up @@ -71,7 +71,7 @@ export interface GithubIssue {
}

/** An example database that the data source uses to retrieve data for the table. */
export class ExampleHttpDao {
export class ExampleHttpDatabase {
constructor(private http: HttpClient) {}

getRepoIssues(sort: string, order: string, page: number): Observable<GithubApi> {
Expand Down