Skip to content

Comments

feat(@schematics/angular): add skipProvidedIn option to service schem…#31669

Closed
MeAkib wants to merge 1 commit intoangular:mainfrom
MeAkib:feat/clli-service-skip-providerIn
Closed

feat(@schematics/angular): add skipProvidedIn option to service schem…#31669
MeAkib wants to merge 1 commit intoangular:mainfrom
MeAkib:feat/clli-service-skip-providerIn

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
@alan-agius4
Copy link
Collaborator

Closing as per #31670 (comment)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add skipProvidedIn option to service schematic

2 participants