If a service is provided in a lazy-loaded module's providers array, when will the service instance be created?

  • When the application starts.
  • When the lazy-loaded module is loaded.
  • When the service is explicitly requested using a constructor.
  • When the service is imported in the root module.
If a service is provided in a lazy-loaded module's providers array, the service instance will be created when the lazy-loaded module is loaded. Lazy-loaded modules are loaded on-demand, so their services are also instantiated when the module is accessed. This can help reduce unnecessary service instantiation and improve application performance.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *