feat: challenge 54 pipe obs signal (#903)

This commit is contained in:
Laforge Thomas
2024-06-17 20:51:27 +02:00
committed by GitHub
parent e6fd5468e2
commit d49cbc0de8
26 changed files with 417 additions and 25 deletions

View File

@@ -0,0 +1,34 @@
import { AsyncPipe } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
inject,
Input,
} from '@angular/core';
import { CurrencyPipe } from './currency.pipe';
import { CurrencyService } from './currency.service';
import { Product } from './product.model';
@Component({
standalone: true,
selector: 'tr[product-row]',
template: `
<td>{{ productInfo.name }}</td>
<td>{{ productInfo.priceA | currency | async }}</td>
<td>{{ productInfo.priceB | currency | async }}</td>
<td>{{ productInfo.priceC | currency | async }}</td>
`,
imports: [AsyncPipe, CurrencyPipe],
providers: [CurrencyService],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProductRowComponent {
protected productInfo!: Product;
@Input({ required: true }) set product(product: Product) {
this.currencyService.updateCode(product.currencyCode);
this.productInfo = product;
}
currencyService = inject(CurrencyService);
}