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?

  1. Put the logic of that service method into the service constructor instead.
  2. Use a factory provider at the root AppModule level that depends on the service to call that service method.
  3. it is not possible to do it at application start; you can do it only at a component level.
  4. 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.