johnpapa / vscode-angular-snippets

Angular Snippets for VS Code
MIT License
575 stars 163 forks source link

Why does the ngFor-TrackBy html extension create a "item.id" and not use a function call? #132

Open Chewieez opened 3 years ago

Chewieez commented 3 years ago

https://github.com/johnpapa/vscode-angular-snippets/blob/c010f9e6a11203358d3c66db4df4c7062a6c8f78/snippets/html.json#L24

This code above is the line in question. I am using the Angular snippets to speed up ngFor TrackBy usage. I first saw the extension in my .html file but Angular showed an error that it didn't know the value of item in trackBy: item.id. After researching I saw it appears the trackBy should call a function and not be assigned to a property of item. Then I found the a-trackby extension in the .ts file to create a trackBy function. Should these 2 extensions (the html and ts) ones work together? Should the html extension create this markup instead *ngFor="let item of list; trackBy: trackBy"?

johnpapa commented 3 months ago

good question, im not aware of how they can be. any ideas?