docs: use the @service decorator in the first-app and signals tutorials by erkamyaman · Pull Request #69381 · angular/angular
Update the services in the first-app and signals tutorials to use the
@Service() decorator instead of @Injectable({providedIn: 'root'}).
This affects HousingService (first-app steps 10-14) and CartStore
(signals step 7).
PR Checklist
Please check that your PR fulfills the following requirements:
- The commit message follows our guidelines: https://github.com/angular/angular/blob/main/contributing-docs/commit-message-guidelines.md
- Tests for the changes have been added (for bug fixes / features)
- Docs have been added / updated (for bug fixes / features)
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
What is the current behavior?
The first-app tutorial (HousingService, steps 10-14) and the signals
tutorial (CartStore, step 7) still introduce services with
@Injectable({providedIn: 'root'}). The essentials guide, the in-depth
dependency injection guides, and the learn-angular DI tutorial have
already adopted the newer @Service decorator, leaving these tutorials
out of step with the rest of the docs.
What is the new behavior?
Both tutorials use @Service(). Since @Service() is an ergonomic
shorthand for @Injectable({providedIn: 'root'}) (it defaults to
autoProvided: true), the examples behave identically while teaching the
recommended modern API. The signals step 7 README snippet is updated to
match.
Does this PR introduce a breaking change?
- Yes
- No