In my TypeScript code, I've encountered an issue where the `copyColumns` data is not accessible inside a recursive function named `rec`, despite being accessible outside of it. Can someone help me identify what's wrong in my code?
When I run console.log(this.copyColummns);
, it returns undefined.
copyNodeHandler ( column, node ) {
this.copyHeaders = [];
this.copyHeadersDeepCopy = [];
for ( let i = 0; i < node[ 0 ].values.length; i++ ) {
this.copyHeaders.push(node[ 0 ].values[ i ].parameterId)
}
this.copyColumns = node;
}
setBinary(rowId, vId, data) {
console.log(this.copyColumns); // This prints fine
let rec = function (pri, pvi) {
console.log(pri + '' + pvi);
console.log(this.copyColumns); // This does not work and returns undefined.
let latest = [];
if (this.copyColumns[pri]) {
this.copyColumns[pri].values[pvi].active = true;
let x = this.copyColumns[pri].values[pvi]
rec(x.pri, x.pvi)
}
};
rec(data.pri, data.pvi)
}