mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 14:23:02 -05:00
feat(challenge16): di
This commit is contained in:
17
apps/di/src/app/currency.pipe.ts
Normal file
17
apps/di/src/app/currency.pipe.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { inject, Pipe, PipeTransform } from '@angular/core';
|
||||
import { map } from 'rxjs';
|
||||
import { CurrencyService } from './currency.service';
|
||||
|
||||
@Pipe({
|
||||
name: 'currency',
|
||||
standalone: true,
|
||||
})
|
||||
export class CurrencyPipe implements PipeTransform {
|
||||
currencyService = inject(CurrencyService);
|
||||
|
||||
transform(price: number) {
|
||||
return this.currencyService.symbol$.pipe(
|
||||
map((s) => `${String(price)}${s}`)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user