Skip to content

Instantly share code, notes, and snippets.

@SaurabhLpRocks
Created May 10, 2018 09:10
Show Gist options
  • Select an option

  • Save SaurabhLpRocks/e270b3d968db9e63f43d5fab7ddf47d9 to your computer and use it in GitHub Desktop.

Select an option

Save SaurabhLpRocks/e270b3d968db9e63f43d5fab7ddf47d9 to your computer and use it in GitHub Desktop.
@Component({
selector: 'app',
template: `<ul>
  <li *ngFor="let item of items; trackBy: trackById">{{item.name}}</li>
</ul>`
})
class AppComponent {
Items = [
{
id: 1,
name: 'item 1'
}, {
id: 2,
name: 'item 2'
},
...
];
trackById(index, item) {
return item.id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment