Skip to content

Commit

Permalink
docs: adjust track by doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Sep 18, 2023
1 parent 9bf2827 commit 450d82e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions docs/src/content/docs/utilities/trackby-id-prop.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import { TRACK_BY_DIRECTIVES } from 'ngxtension/trackby-id-prop';
import { TrackById, TrackByProp } from 'ngxtension/trackby-id-prop';
```

```
```

## Usage

If the items that you iterate with ngFor has an `id` prop (**case-sentitive**!) than you can simple use `trackById` otherwise you can specify the field to be used to track your items using the other directive: `trackByProp:'PROP_NAME'`
Expand All @@ -29,14 +25,14 @@ import { TRACK_BY_DIRECTIVES } from 'ngxtension/trackby-id-prop';
standalone: true,
imports: [TRACK_BY_DIRECTIVES, CommonModule],
template: `
<!-- πŸ‘‡ -->
<ul *ngFor="let item of arr; trackById">
// πŸ‘ˆ
<li>{{ item.name }}</li>
</ul>
<p *ngFor="let item of arr; trackByProp: 'name'">// πŸ‘ˆ {{ item.name }} @{{ item.id }}</p>
<!-- πŸ‘‡ -->
<div *ngFor="let item of arr; trackByProp: 'other'">
// πŸ‘ˆ
<!-- THIS WILL FAIL AND ERROR IF PROP 'other' DOESN'T EXIST IN arr ITEMS -->
{{ item | json }}
</div>
Expand Down

0 comments on commit 450d82e

Please sign in to comment.