Skip to content

Commit 7386ea1

Browse files
LayZeeDKjosephperrott
authored andcommitted
fix(material): fix table generator schematic (#16204)
Import `MatTable` (used in `ViewChild` query). Add `static` option to view queries for future support of Angular version 9.
1 parent 0073301 commit 7386ea1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AfterViewInit, Component, OnInit, ViewChild<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
2-
import { MatPaginator, MatSort } from '@angular/material';
2+
import { MatPaginator, MatSort, MatTable } from '@angular/material';
33
import { <%= classify(name) %>DataSource, <%= classify(name) %>Item } from './<%= dasherize(name) %>-datasource';
44

55
@Component({
@@ -16,9 +16,9 @@ import { <%= classify(name) %>DataSource, <%= classify(name) %>Item } from './<%
1616
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
1717
})
1818
export class <%= classify(name) %>Component implements AfterViewInit, OnInit {
19-
@ViewChild(MatPaginator) paginator: MatPaginator;
20-
@ViewChild(MatSort) sort: MatSort;
21-
@ViewChild(MatTable) table: MatTable<<%= classify(name) %>Item>;
19+
@ViewChild(MatPaginator, {static: false}) paginator: MatPaginator;
20+
@ViewChild(MatSort, {static: false}) sort: MatSort;
21+
@ViewChild(MatTable, {static: false}) table: MatTable<<%= classify(name) %>Item>;
2222
dataSource: <%= classify(name) %>DataSource;
2323

2424
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */

0 commit comments

Comments
 (0)