Skip to content

Needs improvement: MatTextColumn is calling dataAccessor method inside the template. #28208

Open
@Wilt

Description

@Wilt

Description

Call of dataAccessor method is against Angular best practices and will be bad for performance in tables with large data sets.

<td mat-cell *matCellDef="let data" [style.text-align]="justify">
    {{dataAccessor(data, name)}}
</td>

See line 30 inside MatTextColumn for reference.

Reproduction

See the Stackblitz and the example for mat-text-column inside the documentation here for a working example.

Expected Behavior

Set the data in a variable inside the component on initialization and bind that to the template instead.

Actual Behavior

It gets the data inside the template by calling the dataAccessor method.

Environment

  • Angular:
  • CDK/Material:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: cdk/tablearea: material/tableperfThis issue is related to performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions