import { TableComponent } from '@angular-challenges/angular/di'; import { AsyncPipe, NgFor } from '@angular/common'; import { Component, Directive } from '@angular/core'; import { CurrencyPipe } from './currency.pipe'; import { CurrencyService } from './currency.service'; import { Product, products } from './product.model'; interface ProductContext { $implicit: Product; } @Directive({ selector: 'ng-template[product]', standalone: true, }) export class ProductDirective { static ngTemplateContextGuard( dir: ProductDirective, ctx: unknown ): ctx is ProductContext { return true; } } @Component({ standalone: true, imports: [TableComponent, CurrencyPipe, AsyncPipe, NgFor, ProductDirective], providers: [CurrencyService], selector: 'app-root', template: `
| {{ col }} | |||
|---|---|---|---|
| {{ product.name }} | {{ product.priceA | currency | async }} | {{ product.priceB | currency | async }} | {{ product.priceC | currency | async }} |