Track By Key

The trackByKey directive will create function for *ngFor directive and will be using as trackBy.

Using trackByKey

An example in COMPONENT.template.html.

<ng-container *ngFor="
  let item of [
    { animal: '🦊' },
    { animal: 'πŸ¦„' }
  ] trackByKey 'animal'">
  {{ item.animal }}
</ng-container>

Last updated