Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What does the @Injectable({ providedIn: 'root' }) decorator do?

  1. A Creates a new instance per component
  2. B Registers the service as an application-wide singleton that is tree-shakable
  3. C Prevents the service from being injected
  4. D Registers it only in lazy-loaded modules
Answer

Registers the service as an application-wide singleton that is tree-shakable

providedIn root gives one instance for the whole application and allows the service to be dropped from the bundle if nothing injects it.

All Angular MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as