angular-tree-component icon indicating copy to clipboard operation
angular-tree-component copied to clipboard

getFirstRoot not work in async/await

Open YongChingShieh opened this issue 4 years ago • 3 comments

getFirstRoot not work in async/await

my code:

async ngOnInit(): Promise<void> { await this.initTree(); } async initTree(): Promise<void> { const obj = await this.http.post("api/Dictionary/GetDicInfoTree").toPromise(); this.nodes = generateTree(JSON.parse(obj.Extension)); let firstroot = this.tree.treeModel.getFirstRoot(); console.log(firstroot); console.log(this.tree.treeModel); console.log(this.nodes); };

this.tree.treeModel.getFirstRoot() is null but this.nodes is not null

QQ截图20210219150028

YongChingShieh avatar Feb 19 '21 07:02 YongChingShieh

Hi @yongqingxie, what version of the tree are you using? We did a fix for this yesterday. It's in version 11.0.3. Version 11.0.0 - 11.0.2 have wrong getFirstRoot calls. Can you try the new version and let me know?

tobiasengelhardt avatar Feb 19 '21 10:02 tobiasengelhardt

Hi @yongqingxie, what version of the tree are you using? We did a fix for this yesterday. It's in version 11.0.3. Version 11.0.0 - 11.0.2 have wrong getFirstRoot calls. Can you try the new version and let me know? this my version info "@angular/core": "~11.1.0", "@angular/cli": "~11.1.1", "@angular/compiler-cli": "~11.1.0", "@angular/language-service": "~11.1.0", "@circlon/angular-tree-component": "^11.0.3", if i use async/await
getFirstRoot is null getNodeById and getNodeByPath is undefined

YongChingShieh avatar Feb 19 '21 11:02 YongChingShieh

We had a bit of trouble removing lodash so I thought it might be related. But it's not. I can reproduce this as well. Will take a look into it and keep you updated.

tobiasengelhardt avatar Feb 19 '21 17:02 tobiasengelhardt