UNPKG

ng-shopping-cart

Version:

An Angular component library to create shopping carts

62 lines (61 loc) 1.88 kB
import { PipeTransform } from '@angular/core'; /** * A pipe that wraps the `CurrencyPipe` to set currency value display using a string rather than several arguments for easy configuration. * * @summary * It takes a string as a single parameter in the format `'currencyCode:symbol:digitsInfo:locale'`. You can also use the special * value `'auto'` which will set the default used by Angular in that specific configuration. * * Every configuration is optional and not using any arguments or an argument of `'auto'`is equivalent to how the `CurrencyPipe` works by * default. If no locale is specified uses the current locale to format numbers. * * @note {info} A value of `'auto:auto:auto:auto'` is equivalent to simply using `'auto'`. * * @note {danger} In Angular versions lower than 6 the `CurrencyPipe` does not change the currency symbol if you don't specify a different * `currencyCode` * * @howToUse "With a different currency symbol" * ```html * <span> * {{ value | cartCurrency:format }} * </span> * ``` * ```typescript * export class MyComponent { * value = 10; * format = 'EUR'; * } * ``` * * @howToUse "With a five digits after the decimal point" * ```html * <span> * {{ value | cartCurrency:format }} * </span> * ``` * ```typescript * export class MyComponent { * value = 10.56; * format = 'auto:auto:1.5-5'; * } * ``` * * @howToUse "With a different locale" * ```html * <span> * {{ value | cartCurrency:format }} * </span> * ``` * ```typescript * export class MyComponent { * value = 10; * format = 'auto:auto:auto:en-GB'; * } * ``` */ export declare class CartCurrencyPipe implements PipeTransform { private _locale; private currencyFormatter; constructor(_locale: string); transform(value: any, format?: string): any; }