ng-shopping-cart
Version:
An Angular component library to create shopping carts
123 lines (122 loc) • 3.75 kB
TypeScript
import { OnInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
import { CartItem } from '../../classes/cart-item';
import { CartService } from '../../services/cart.service';
import { CartViewDisplay } from '../../types';
import { LocaleFormat } from '../../interfaces/locale-format';
/**
* Renders a view of the cart.
*
* @order 2
* @howToUse "Using responsive layout"
* ```html
* <cart-view [display]="'responsive'">
* </cart-view>
* ```
*
* @howToUse "No images and using scrollbars on small screens"
* ```html
* <cart-view [images]="false" [display]="'responsive-table'">
* </cart-view>
* ```
*
* @howToUse "Using different text for headers"
* ```html
* <cart-view [emptyText]="headers.empty" [nameHeaderText]="headers.name" [quantityHeaderText]="headers.quantity"
* [priceHeaderText]="headers.quantity" [totalHeaderText]="headers.total" [taxFooterText]="footers.tax"
* [shippingFooterText]="footers.shipping" [totalFooterText]="footers.total"
* >
* </cart-view>
* ```
* ```typescript
* export class MyComponent {
* headers = {
* empty: 'No items. Add some to the cart',
* name: 'Description',
* quantity: 'Amount',
* price: 'Cost',
* total: 'Total x item',
* }
* footers = {
* tax: 'Tax rate',
* shipping: 'Shipping cost',
* total: 'Total cost'
* }
* }
* ```
*
* @howToUse "Change the default empty cart content"
* ```html
* <cart-view [customEmptyContent]="true">
* <div class="my-empty-cart-view">
* <span style="font-size: 36px;" class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>
* Your cart is empty
* </div>
* </cart-view>
* ```
*/
export declare class CartViewComponent implements OnInit, OnChanges, OnDestroy {
private cartService;
private _serviceSubscription;
/**
* Changes the appearance how the cart view displays in different screen sizes
*/
display: CartViewDisplay;
/**
* Whether to include images in the cart or not.
*/
images: boolean;
/**
* The text to show when the cart has no items in it.
*/
emptyText: string;
/**
* When set to `true` and the cart is empty displays the projected content of the component as the empty content.
*/
customEmptyContent: boolean;
/**
* The text to display in the header of the name column.
*/
nameHeaderText: string;
/**
* The text to display in the header of the quantity column.
*/
quantityHeaderText: string;
/**
* The text to display in the header of the price column.
*/
priceHeaderText: string;
/**
* The text to display in the header of the total per item column.
*/
totalHeaderText: string;
/**
* The text to display in the tax section of the footer.
*/
taxFooterText: string;
/**
* The text to display in the shipping section of the footer.
*/
shippingFooterText: string;
/**
* The text to display in the total section of the footer.
*/
totalFooterText: string;
/**
* Changes currency display format for the component. Overrides the value set from the service using `setCurrencyFormat`.
*/
localeFormat: string;
format: LocaleFormat;
empty: boolean;
items: CartItem[];
taxRate: number;
tax: number;
shipping: number;
cost: number;
constructor(cartService: CartService<any>);
update(): void;
increase(item: CartItem): void;
decrease(item: CartItem): void;
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
}