1.showing a loader until API resolvers 2. After a getting API response, setting the loader flag to false, and trying to read the div inside flag 3. Flag value is updated but dom is not refreshed, so i dont have reference to a div inside a if condition
Why dom is not refreshed here..
A constructor shouldn't have async code in it. There are ways to get it to work, but Angular provides various lifecycle events that should be utilized instead.
ngAfterViewInitwould be my recommendation here as follows:The docs on
AfterContenthooks explain that content 'children' aren't available until one of these hooks.Stackblitz