Tree component get nodes sync

This week, I will continue my plan to find the possibility of helping in the “NG-ZORRO” project. Not long ago, I was looking for a new bug. I will contribute to this bug.

Link: https://github.com/NG-ZORRO/ng-zorro-antd/issues/3076

In this study, I found that the questioner raised questions about “Tree component can not get nodes sync , treeService undefined” and uploaded a part of the code.

QQ截图20190315011121.png

After looking at the code, I found that the questioner may not be clear about Angular’s knowledge. The description of ‘OnInit’ is “Initialize the directive/component after Angular first displays the data-bound properties and sets the directive/component’s input properties.” It means the clild view/component is not initialized at this stage. The requirement of accessing To the child component at ‘OnInit’ stage is not possible. The correct life-cycle hook should be use is “AfterViewInit – Respond after Angular initializes the component’s views and child views / the view that a directive is in”

To do this, I tried to modify the code. The bug is fixed.

QQ截图20190315011958.png

Link: https://stackblitz.com/edit/angular-qwlewn-rlqbtu?file=src/app/app.component.ts

In the future, I hope to continue to help in the “NG-ZORRO” project, and I am not only in this project.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s