| import { AfterViewInit, Component, OnInit, ViewChild<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core'; |
| import { MatPaginator } from '@angular/material/paginator'; |
| import { MatSort } from '@angular/material/sort'; |
| import { MatTable } from '@angular/material/table'; |
| import { <%= classify(name) %>DataSource, <%= classify(name) %>Item } from './<%= dasherize(name) %>-datasource'; |
| |
| @Component({ |
| selector: '<%= selector %>',<% if(inlineTemplate) { %> |
| template: ` |
| <%= indentTextContent(resolvedFiles.template, 4) %> |
| `,<% } else { %> |
| templateUrl: './<%= dasherize(name) %>.component.html',<% } if(inlineStyle) { %> |
| styles: [` |
| <%= indentTextContent(resolvedFiles.stylesheet, 4) %> |
| `]<% } else { %> |
| styleUrls: ['./<%= dasherize(name) %>.component.<%= style %>']<% } %><% if(!!viewEncapsulation) { %>, |
| encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>, |
| changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %> |
| }) |
| export class <%= classify(name) %>Component implements AfterViewInit, OnInit { |
| @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator; |
| @ViewChild(MatSort, {static: false}) sort: MatSort; |
| @ViewChild(MatTable, {static: false}) table: MatTable<<%= classify(name) %>Item>; |
| dataSource: <%= classify(name) %>DataSource; |
| |
| /** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */ |
| displayedColumns = ['id', 'name']; |
| |
| ngOnInit() { |
| this.dataSource = new <%= classify(name) %>DataSource(); |
| } |
| |
| ngAfterViewInit() { |
| this.dataSource.sort = this.sort; |
| this.dataSource.paginator = this.paginator; |
| this.table.dataSource = this.dataSource; |
| } |
| } |