How does Angular2: get elements under the control of * ngIf?

page code: < div id="d" * ngIf = "show" > < / div >
ts file: in the callback function for which the request is successful:
this.show = true;
document.getElementById ("d")
at this time it is null,. I guess because dom hasn"t been rendered yet, try to change the div, to
this.show = true;
setTimeout (() = > {
document.getElementById ("d");
}, 100);
you can get dom, at this time, but it is not clear whether this will be a problem. Is there a better way?

Mar.01,2021

you can try ngAfterChecked


because I'm going to init an echart form after I get dom. So far, three solutions have been found: 1. Is the method mentioned in the question, which is executed in the callback of setTimeout and set a time. two Use [hidden] to control. 3. Make the parts that need to be controlled into subcomponents

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b331f8-2be67.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b331f8-2be67.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?