-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed as not planned
Description
Command
generate
Description
Currently, when generating a service using ng g s service-name, the CLI always generates the service with providedIn: 'root' in the Injectable decorator.
For applications that prefer to manually provide services in specific modules or components rather than using the tree-shakeable pattern, developers must manually remove this metadata every time a service is generated.
Describe the solution you'd like
Generate service without providedIn (new behavior)
ng g s my-service --skip-provided-in
Generate service with providedIn: 'root' (default, current behavior)
ng g s my-service
Expected Output with --skip-provided-in:
import { Injectable } from '@angular/core';
@Injectable()
export class MyService {}
Current Output (default behavior, unchanged):
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MyService {
}
Configuration Support
{
"schematics": {
"@schematics/angular:service": {
"skipProvidedIn": true
}
}
}
Metadata
Metadata
Assignees
Labels
No labels