Skip to content

Conversation

@MeAkib
Copy link
Contributor

@MeAkib MeAkib commented Nov 1, 2025

…atic

Add a new skipProvidedIn boolean option to the service schematic that allows developers to generate services without the providedIn: 'root' metadata in the @Injectable decorator. When set to true, the decorator will be rendered as @Injectable() instead of @Injectable({ providedIn: 'root' }).

This provides flexibility for developers who prefer to manually provide services in specific modules or components rather than using the default tree-shakeable pattern.

The option defaults to false to maintain backward compatibility and continue encouraging Angular's best practice of tree-shakeable services.

Fixes #31670

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #31670

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @schematics/angular labels Nov 1, 2025
…atic

Add a new `skipProvidedIn` boolean option to the service schematic that allows
developers to generate services without the `providedIn: 'root'` metadata in
the @Injectable decorator. When set to true, the decorator will be rendered as
`@Injectable()` instead of `@Injectable({ providedIn: 'root' })`.

This provides flexibility for developers who prefer to manually provide services
in specific modules or components rather than using the default tree-shakeable
pattern.

The option defaults to false to maintain backward compatibility and continue
encouraging Angular's best practice of tree-shakeable services.

fixes angular#31670
@MeAkib MeAkib force-pushed the feat/clli-service-skip-providerIn branch from e3378aa to b1e9e7a Compare November 1, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add skipProvidedIn option to service schematic

1 participant