Skip to content

Commit 017a541

Browse files
authored
fix(material/schematics): fix template diagnostic in table schematic (#27407)
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 #27329.
1 parent 755194a commit 017a541

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</table>
1818

1919
<mat-paginator #paginator
20-
[length]="dataSource?.data?.length"
20+
[length]="dataSource.data.length"
2121
[pageIndex]="0"
2222
[pageSize]="10"
2323
[pageSizeOptions]="[5, 10, 20]"

src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ export class <%= classify(name) %>Component implements AfterViewInit {
2323
@ViewChild(MatPaginator) paginator!: MatPaginator;
2424
@ViewChild(MatSort) sort!: MatSort;
2525
@ViewChild(MatTable) table!: MatTable<<%= classify(name) %>Item>;
26-
dataSource: <%= classify(name) %>DataSource;
26+
dataSource = new <%= classify(name) %>DataSource();
2727

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

31-
constructor() {
32-
this.dataSource = new <%= classify(name) %>DataSource();
33-
}
34-
3531
ngAfterViewInit(): void {
3632
this.dataSource.sort = this.sort;
3733
this.dataSource.paginator = this.paginator;

0 commit comments

Comments
 (0)