Hi everyone, I was hoping I could get some advice on how to deal with the following issue:
I have a factory that initializes google maps, added in my app.js, and called after the standard window.statusbar check. When the app loads in a browser, I get “TypeError: Cannot read property ‘firstChild’ of null” - meaning the templates are not loaded yet and my getElementById in the map initializer finds nothing, I assume. Hitting refresh solves this, the map loads. The problem is also gone if I move the map inifializing function directly into a controller.
My question: is there a way to keep the initializer in the factory, and somehow wait for the DOM to load, then call it? I tried a few things - moving the scripts to line just before , tried calling it inside window.onload, ionic.DomUtils.ready(), document.addEventListener(“load”, …), but nothing seems to work. On top of that, on a device, but not in the browser, I get a warning when debugging: “ionic handling of touchstart input event was delayed for 1488052293443 ms”, when I call the factory map initializer from the controller, but not when I call it in the app.js.
Has anyone encountered this? Thanks in advance for any help.