Here's the scenario, i need to pass the index of the element to a click event rather that the item itself, but the next code gives error when i just basically took it from the Angular 2 docs:
< ion-item *ngFor="#prod of products; #i = index" (click)="editProduct(i)">
and error:
EXCEPTION: Error during evaluation of "click"
(index):29 EXCEPTION: Error during evaluation of "click"console.(anonymous function) @ (index):29BrowserDomAdapter.logError @ app.bundle.js:37269BrowserDomAdapter.logGroup @ app.bundle.js:37279ExceptionHandler.call @ app.bundle.js:10953(anonymous function) @ app.bundle.js:20193NgZone._notifyOnError @ app.bundle.js:20829errorHandling.onError @ app.bundle.js:20727run @ app.bundle.js:5141(anonymous function) @ app.bundle.js:20742NgZone.run @ app.bundle.js:20691outsideHandler @ app.bundle.js:35609run @ app.bundle.js:5138zoneBoundFn @ app.bundle.js:5111
(index):29 ORIGINAL EXCEPTION: ReferenceError: i is not defined
Note that last line says ReferenceError: i is not defined
which means that i doesn't exist for the (click)
event, but inside i have an interpolation that shows the index and it is correct, how do i pass the index to the (click)
event?