Can someone explain why this is wrong? splitval is most definitely a function. I created a stackblitz with the code here- check console for error
function call:
[(this.filcol, this.strtrans)] = (d.trans as Transform).splitval();
Output:
edit trans:{"val":"fil.SalesOrderNo=.slice(0,7)","note":""} TypeError: d.trans.splitval is not a function
Class:
export class Transform {
val: string;
note: string;
splitval(): [string, string] {
try {
let filcol = this.val.substr(0, this.val.indexOf("="));
let strtrans = this.val.substr(this.val.indexOf("=") + 1);
return [filcol, strtrans];
} catch (e) {
console.log("err shared model splitval:" + e);
}
}
}
d.transhas that method? The value isd.trans=JSON.parse('{"val":"fil.SalesOrderNo=.slice(0,7)","note":""}'), so it wouldn't have any methods at all.d.transisn't actually an instance ofTransform. Look at the code where that object is generated.