Needs improvement: MatTextColumn is calling dataAccessor method inside the template.
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### 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:
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Refactoring
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100