Skip to content

Commit

Permalink
fix(material/schematics): fix template diagnostic in table schematic
Browse files Browse the repository at this point in the history
Fixes that the table schematic was producing a template diagnostic for null checking a value that doesn't need to be null checked. Also removes an unnecessary constructor.

Fixes angular#27329.
  • Loading branch information
crisbeto committed Jul 5, 2023
1 parent c03b5f4 commit 4f136ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</table>

<mat-paginator #paginator
[length]="dataSource?.data?.length"
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="10"
[pageSizeOptions]="[5, 10, 20]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ export class <%= classify(name) %>Component implements AfterViewInit {
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
@ViewChild(MatTable) table!: MatTable<<%= classify(name) %>Item>;
dataSource: <%= classify(name) %>DataSource;
dataSource = new <%= classify(name) %>DataSource();

/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['id', 'name'];

constructor() {
this.dataSource = new <%= classify(name) %>DataSource();
}

ngAfterViewInit(): void {
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
Expand Down

0 comments on commit 4f136ed

Please sign in to comment.