I have a number of services defined within an AngularJs application. There is a root service that must load, get some data from a server, then the other services that depend on this root service can initialise, and after that the controllers can load and display data on the page.
Th problem is controllers are loading before the root service, and child services, can fully initialise, eg:
- User loads page
- root service starts initialisation
- controller loads, which depends on child service (which depends on root service)
- page binding fails because child service cannot supply data to controller
- root service finishes intialisation (too late)
The initialisation flow I want is this:
- User loads page
- root service starts initialisation
- root service finishes intialisation
- child services which depend on root service initialise
- controller loads, which depends on child service
- page binding succeeds
Is there a technique for handling this kind of problem?