1

I'm trying to reuse some html components in angular as per the solution mentioned here. In my scenario, I have 2 mat tables in a page, with some common columns. I'm trying to put the common columns in a template and reference that template inside my mat-table definitions. But it's not compiling, angular is not able to find the column definitions inside the template. Here is the stackblitz link. Please advise what am I missing.

jijo
  • 765
  • 3
  • 18
  • 35

1 Answers1

0

try using ViewChild:

@ViewChild('CommonColumns') CommonColumns: TemplateRef<any>;

Put that in your ts file. you're trying to reference something that doesn't exist in your ts file with [ngTemplateOutlet].

  • Thanks ! Updated the stackblitz with this code, but still getting the same error. – jijo Jan 08 '19 at 18:51
  • try looking at this it seems like what your looking for https://stackoverflow.com/questions/52812422/angular-material-2-table-define-column-using-templateref-and-ngtemplateoutlet – Gabe Hollander Jan 09 '19 at 19:09