Hi,
options = {
getChildren: (node:TreeNode) => {
return request('/api/children/' + node.id);
}
}
Am trying to get child nodes. in request('/api/children/' + node.id); calling rest services thats returning the child node. Because of asynchronous it's not working. how I can make it synchronous .I need child data needs to be loaded on demand.
Thanks
Hi @chandu58
You need to return Promise object for async data to make it work !
getChildren(node:TreeNode) {
return new Promise((resolve, reject) => {
this.yourService.getChildren(node.data).subscribe(data => {
resolve(data );
}, error => this.onLoadFailed(error));
});
}
Assuming this.yourService.getChildren will be make actual call to your API (('/api/children/' + node.id))
Hope this will help.
Please share the output!
Cheers
Abhi
Hi Abhi,
Thanks so much .. it's working now.
really am struck with this issue.
Cheers
Chandu
Most helpful comment
Hi Abhi,
Thanks so much .. it's working now.
really am struck with this issue.
Cheers
Chandu