Question · Angular course · Module 5: Services and DI

Providers in a Component

What happens when we add a service to 'providers' in the @Component decorator?

Answer options

  • Nothing - that is a syntax error
  • The service becomes a singleton
  • Each component instance gets its own instance of the service
  • The service becomes globally available

You can check the correct answer by solving this task in the CodeWorlds game.