I would like to make a web API call as soon as my app starts. This Http call should return an array of Json objects.
I want to create HTML elements (in my root app) depending on how many elements were returned and then access and display that data in different (child->child->child) components without grinding it down to all those childs from the root app.
I guess I have to create a service
class.
Questions
- Is a service instantiated as soon as the app is started or only when the first component is getting created that uses that service?
- Can I use a promise to achieve my desired behavior or do I have to use observable (BehaviorSubject)?
- According to 2. Is it possible to start a web API call (as soon as app starts) and then check from other indepentend components if the data already exists in my service and use it?
- *ngFor="let name of names"
` to dynamically create a list element for each name returned. I'm not sure if that is of use to you directly but maybe it will be. – Christopher Lake Jul 14 '17 at 11:34