0

I'm using a cache to store data fetched from an API, then using that data to make a chart in a div on my Angular app.

I think the cache returns the data faster than the DOM loads, because when I print console.log(document.getElementByID(div_name), it prints null. The same line prints the right element when the data is fetched from the back-end.

Is there anyway I can make my function wait till the DOM is loaded to query the cache?

Nishant Roy
  • 1,043
  • 4
  • 16
  • 35
  • Can you share some more Info Or some code sample – Saurabh Sarathe Jun 27 '17 at 20:15
  • Can't expose the API. It's literally just an `$http.get` request that gets cached. The `html` is 3 divs that are used to draw a chart on. When the request is sent to the API, it takes 3-4 seconds, then the `divs` are available. When getting the data from the cache, it's basically instant, and the `divs` are unavailable, so the page doesn't load completely. I think @JoelCDoyle's suggested post may work. – Nishant Roy Jun 27 '17 at 20:21

0 Answers0