mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 22:33:03 -05:00
feat: challenge 54 pipe obs signal (#903)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user