/* eslint-disable @angular-eslint/directive-selector */ import { AsyncPipe, NgFor } from '@angular/common'; import { Component, Directive } from '@angular/core'; import { TableModule } from 'primeng/table'; import { CurrencyPipe } from './currency.pipe'; import { CurrencyService } from './currency.service'; import { Product, products } from './product.model'; interface ProductContext { $implicit: Product; } @Directive({ selector: 'ng-template[pTemplate="body"]', standalone: true, }) export class ProductDirective { static ngTemplateContextGuard( dir: ProductDirective, ctx: unknown ): ctx is ProductContext { return true; } } @Component({ standalone: true, imports: [TableModule, 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 }} `, }) export class AppComponent { products = products; displayedColumns = ['name', 'priceA', 'priceB', 'priceC']; }