Skip to content

Commit

Permalink
refactor(admin-ui): Alter the way DataTableComponent selects template
Browse files Browse the repository at this point in the history
This allows other ng-templates to be used inside the row template
  • Loading branch information
michaelbromley committed May 6, 2019
1 parent 3f732ab commit cbfff34
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AfterContentInit,
ChangeDetectionStrategy,
Component,
ContentChild,
Expand All @@ -20,7 +21,7 @@ import { DataTableColumnComponent } from './data-table-column.component';
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [PaginationService],
})
export class DataTableComponent<T> {
export class DataTableComponent<T> implements AfterContentInit {
@Input() items: T[];
@Input() itemsPerPage: number;
@Input() currentPage: number;
Expand All @@ -33,5 +34,10 @@ export class DataTableComponent<T> {
@Output() pageChange = new EventEmitter<number>();
@Output() itemsPerPageChange = new EventEmitter<number>();
@ContentChildren(DataTableColumnComponent) columns: QueryList<DataTableColumnComponent>;
@ContentChild(TemplateRef) rowTemplate: TemplateRef<any>;
@ContentChildren(TemplateRef) templateRefs: QueryList<TemplateRef<any>>;
rowTemplate: TemplateRef<any>;

ngAfterContentInit(): void {
this.rowTemplate = this.templateRefs.last;
}
}

0 comments on commit cbfff34

Please sign in to comment.