Currently, I am attempting to incorporate the *ngFor index into my pipe in the following manner:
<td *ngFor="let course of courses | matchesTime:time | matchesWeekday:i ; index as i">{{course.courseName}}</td>
This is how my pipe is structured:
transform(items: Array<any>, weekday: number): Array<any> {
return items.filter(
item => item.weekday === weekday
);
}
Unfortunately, it appears that the weekday variable ends up being undefined. It seems that the index isn't initialized during the pipe's execution.
UPDATE: To further illustrate this issue, I have created a stackblitz example here: https://stackblitz.com/edit/angular-5-pipe-index-error