Reputation: 86
Below is the code that has the logic that changes the rows, cols, according to my business needs. When I keep this code, in my Angular2 ts code, I am getting Supplied parameters do not match any signature of call target error at .forEach(...
var data = [{ Id: "a", ColumnLocation: "0", RowLocation: "0" }, { Id: "b", ColumnLocation: "0", RowLocation: "1" }, { Id: "4", ColumnLocation: "0", RowLocation: "3" }, { Id: "c", ColumnLocation: "1", RowLocation: "0" }, { Id: "d", ColumnLocation: "1", RowLocation: "2" }, { Id: "e", ColumnLocation: "2", RowLocation: "0" }, { Id: "e", ColumnLocation: "2", RowLocation: "2" }];
data.forEach(function (col, row) {
return function (o) {
if (col !== o.ColumnLocation) {
col = o.ColumnLocation;
row = 0;
}
if (+o.RowLocation !== row) {
o.RowLocation = row.toString();
}
row++;
}
}());
Upvotes: 1
Views: 140
Reputation: 6657
As others mentioned in order to use self executing function with parameters you need to provide those parameters.
let myCol; // or you can set this to an initial value
let myRow;
data.forEach(function (col, row) {
return function (o) {
// your logic here
};
}(myCol, myRow));
Your typescript compiler is complaining because your function takes two parameters col
and row
but you are invoking it without any parameter.
Upvotes: 1