Skip to content

Project content in matCellDef #11783

@catlabs

Description

@catlabs

Bug

I have use the wrapper from the demo app to create my own table around MatTable (https://github.com/angular/material2/tree/master/src/demo-app/table/custom-table)

I would like to create a simple syntax for the end user where they can define the content of the cell in the template, it will look like this

<wrapper-table [dataSource]="wrapperTableDataSource" [columns]="columnsToDisplay">
    <simple-column name="name">
      <td mat-cell *matCellDef="let data"> 
        {{data.name}} 
        <button mat-raised-button color="primary">Action</button>		
      </td>
    </simple-column>
</wrapper-table>

This doesn't work, I guess it is because of ng-content so what I tried is to get the MatCellDef from the transclusion and then associate it to the MatColumnDef

What is the current behavior?

I get this error:
ERROR
Error: StaticInjectorError(AppModule)[MatHeaderCell -> CdkColumnDef]:
StaticInjectorError(Platform: core)[MatHeaderCell -> CdkColumnDef]:
NullInjectorError: No provider for CdkColumnDef!

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: https://stackblitz.com/edit/transclusion-columndef

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions