I am stuck on this code:
this.unwatches[id] = [];
for (let i: number = 0; i < this.columns.length; i++ ) {
this.unwatches[id].push($scope.$watch((): any => {
return entity[this.columns[i].attribute];
}, (newValue: any): void => {
this.grid.cells(id, i).setValue(newValue);
}));
}
and I got this error:
Loop contains block scoped variable 'i' referenced by a function in the loop.
I found this thread: Typescript - closure inside loop
which is exactly my problem, but I got trouble adapt my code. Anyone could help me?