angular / angular/components

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

未关闭
#28,208 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/table area: material/table P4 perf
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Description

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


{{dataAccessor(data, name)}}

See [line 30 inside `MatTextColumn` for reference](https://github.com/angular/components/blob/main/src/material/table/text-column.ts#L30C11-L30C35).

### Reproduction

See [the Stackblitz and the example for `mat-text-column` inside the documentation here for a working example](https://material.angular.io/components/table/examples#table-text-column).

### 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:

贡献指南

打开贡献指南

调研方向

Start by reading src/material/table/text-column.ts around line 30, then run the mat-text-column documentation example and its linked Stackblitz to observe the current behavior. Done means the template no longer calls dataAccessor for each table render, while the example continues to display the expected cell values.

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
重构
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。