Question: When a service requires some setup to initialize its default state through a method, how can you make sure that said method is invoked before the service gets injected anywhere?
- Put the logic of that service method into the service constructor instead.
- Use a factory provider at the root AppModule level that depends on the service to call that service method.
- it is not possible to do it at application start; you can do it only at a component level.
- Instantiate an instance of the service at the global level (window scope) and then call that method.
Answer: The correct answer of the above question is Option B:Use a factory provider at the root AppModule level that depends on the service to call that service method.