File

src/app/search-ui/search-result/pipes/free-price-label.pipe.ts

Description

This pipe is used to format the price of an application. If the current price is $0.00 This will replace the value with a "FREE" label.

Metadata

name freePriceLabel

Methods

transform
transform(value: string, currencySymbol: string, label: string)
Parameters :
Name Type Optional Default value
value string no
currencySymbol string no
label string no 'FREE'
Returns : any
import { Pipe, PipeTransform } from '@angular/core';

/**
 * This pipe is used to format the price of an application. If the current price is $0.00
 * This will replace the value with a "FREE" label.
 */
@Pipe({
  name: 'freePriceLabel'
})
export class FreePriceLabelPipe implements PipeTransform {
  transform(value: string, currencySymbol: string, label: string = 'FREE'): any {
    return Number(value.replace(currencySymbol, '')) === 0 ? label : value;
  }
}

results matching ""

    No results matching ""