You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(@schematics/angular): generate services without a .service extension/type
To align with the updated style guide, Angular v20 will generate services
without a `.service` file extension type for all service related
files by default. Projects will automatically use this naming convention.
Projects can however opt-out by setting the `type` option to `Service`
for the service schematic. This can be done as a default in the `angular.json`
or directly on the commandline via `--type=Service` when executing `ng generate`.
As an example, `example.service.ts` will now be named `example.ts`. Additionally,
the TypeScript class name will be `Example` instead of the previous `ExampleService`.
Copy file name to clipboardexpand all lines: packages/schematics/angular/service/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
3
3
@Injectable({
4
4
providedIn: 'root'
5
5
})
6
-
export class <%= classify(name) %>Service {
6
+
export class <%= classify(name) %><%= classify(type) %> {
Copy file name to clipboardexpand all lines: packages/schematics/angular/service/files/__name@dasherize@if-flat__/__name@dasherize__.service.spec.ts.template
Copy file name to clipboardexpand all lines: packages/schematics/angular/service/schema.json
+4
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,10 @@
39
39
"type": "boolean",
40
40
"description": "Skip the generation of a unit test file `spec.ts` for the service.",
41
41
"default": false
42
+
},
43
+
"type": {
44
+
"type": "string",
45
+
"description": "Append a custom type to the service's filename. For example, if you set the type to `service`, the file will be named `my-service.service.ts`."
0 commit comments