151
rated 0 times
[
153]
[
2]
/ answers: 1 / hits: 19602
/ 7 Years ago, wed, april 19, 2017, 12:00:00
I am trying to call the following function recursively.
public getData(key,value){
this.htmlString += '<span style=color:cornflowerblue>'+key+' </span>:';
if(value instanceof Object){
Object.keys(value).forEach(function (keydata) {
let obj = value[keydata];
this.getData(keydata,value[keydata]);
console.log(key,obj,obj instanceof Object)
});
}else{
this.htmlString += '<span>'+value+'</span>';
}
return this.htmlString;
};
when i tried to call teh function it was showing an error Cannot read property 'getData' of undefined. Is there any wrong in the code or any other way to do this.
More From » angular