angular / angular/components

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

Ouverte
#28,208 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area: cdk/table area: material/table P4 perf
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Refactorisation
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.