Hi all - hope someone can shed a little light, or at least give me a shove down the right path .
I have a custom Class, “Election”, that takes an XML filename as a parameter, uses http.get to retrieve it, converts it from XML to JSON, then creates a few more objects based on parsing the contents. A large XML file can take nearly 10 seconds to process. However, the html template (let’s call it electionPage) has already rendered with no data because the Election object was empty when it rendered.
How can I force the html template to render AFTER the Election object has been completely created and is ready to use? Is the proper way to do this to make my Election object return a Promise, and then I could do this:
let election = new Election(“file.xml”).then(navController.push(electionPage));
If so, how do I create the Promise? I’ve seen that other objects implicitly return them (i.e. http), but can’t find anything on creating the Promise in my constructor myself.
Should I be using Observable, instead?