docs: use the @Service decorator in the first-app and signals tutorials

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).
This commit is contained in:
yamanerkam
2026-06-16 15:42:44 +03:00
committed by Kirill Cherkashin
parent c23ddd6a99
commit e7a4e25318
9 changed files with 17 additions and 33 deletions
@@ -1,8 +1,6 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
@@ -1,9 +1,7 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
@@ -1,9 +1,7 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
@@ -1,9 +1,7 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
@@ -1,9 +1,7 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
url = 'http://localhost:3000/locations';
@@ -1,9 +1,7 @@
import {Injectable} from '@angular/core';
import {Service} from '@angular/core';
import {HousingLocationInfo} from './housinglocation';
@Injectable({
providedIn: 'root',
})
@Service()
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
@@ -13,7 +13,7 @@ Add readonly and computed signals to make the cart state reactive in `cart-store
```ts
// Add the computed import
import {Injectable, signal, computed} from '@angular/core';
import {Service, signal, computed} from '@angular/core';
// Then add these signals to the class:
@@ -1,9 +1,7 @@
import {Injectable, signal, computed} from '@angular/core';
import {Service, signal, computed} from '@angular/core';
import {CartItem} from './cart-types';
@Injectable({
providedIn: 'root',
})
@Service()
export class CartStore {
private items = signal<CartItem[]>([]);
@@ -1,10 +1,8 @@
// TODO: Import computed from @angular/core
import {Injectable, signal} from '@angular/core';
import {Service, signal} from '@angular/core';
import {CartItem} from './cart-types';
@Injectable({
providedIn: 'root',
})
@Service()
export class CartStore {
private items = signal<CartItem[]>([]);