ng-shopping-cart
Version:
An Angular component library to create shopping carts
62 lines (61 loc) • 2.37 kB
TypeScript
import { OnInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
import { CartService } from '../../services/cart.service';
import { LocaleFormat } from '../../interfaces/locale-format';
/**
* Renders a summary of the contents of the cart.
*
* @order 3
* @howToUse "With a different icon"
* ```html
* <cart-summary [icon]="'http://myapi/assets/icon.svg'"></cart-summary>
* ```
*
* @howToUse "Display different words when the cart changes"
* ```html
* <cart-summary [noItemsText]="'Zero items'" [oneItemText]="'Single item'" [manyItemsText]="'Exactly # items'"></cart-summary>
* ```
*
* @howToUse "Using always a number to display item count"
* ```html
* <cart-summary [noItemsText]="'# items'" [oneItemText]="'# items'" [manyItemsText]="'# items'"></cart-summary>
* ```
*
* @note {info} Inputs that allows you to customize text also accept the special character `#` to use numbers instead of words to
* specify quantity, for example `'# bla'` will update to `'0 bla'` or `'1 bla'` when the number of items in the cart change.
*/
export declare class CartSummaryComponent implements OnInit, OnChanges, OnDestroy {
private cartService;
private _serviceSubscription;
/**
* The url of an icon to show on the summary. Use this to replace the default icon which is an svg with the image of a shopping cart.
*
* To use the default icon when you are using the `[icon]` input just set it to a falsy value, eg: `null`, `undefined`, `''`, etc.
*/
icon: string;
/**
* The text to display when there are no items in the cart.
*/
noItemsText: string;
/**
* The text to display when there is only one item in the cart.
*/
oneItemText: string;
/**
* The text to display when there are several items in the cart.
*/
manyItemsText: string;
/**
* Changes currency display format for the component. Overrides the value set from the service using `setCurrencyFormat`.
*/
localeFormat: string;
itemsText: any;
totalItems: number;
totalCost: number;
format: LocaleFormat;
constructor(cartService: CartService<any>);
private updateItemsText();
private updateComponent();
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
}