I find myself writing stuff like this all the time:
<div *ngFor="let mouse of mice; let i=index" ...
Inside the loop I would then hand i on as a variable to a method when a button is clicked or something. My superior is not in love with the i and prefers if possible that there be a convenience method to call on the type of which there is a collection of that type which is being looped through. So if mice where an Array<Mouse> then instead of having a button (click) event call doWhatever(i); there would instead be a .doWhatever() hanging off of mouse which would do the same thing. This may not always be possible, but think about it.
No comments:
Post a Comment