angular / angular/components

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

Offen
#28,208 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: cdk/table area: material/table P4 perf
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Refactoring
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.