mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Kirill Cherkashin
parent
c23ddd6a99
commit
e7a4e25318
@@ -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';
|
||||
|
||||
|
||||
+2
-4
@@ -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:
|
||||
|
||||
|
||||
+2
-4
@@ -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[]>([]);
|
||||
|
||||
|
||||
+2
-4
@@ -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[]>([]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user