diff --git a/src/app/store/cart/cart.component.html b/src/app/store/cart/cart.component.html index d5e1941..3afd6da 100644 --- a/src/app/store/cart/cart.component.html +++ b/src/app/store/cart/cart.component.html @@ -1,36 +1,37 @@
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
No. {{i}} Name {{element.name}} Weight {{element.weight}} Symbol {{element.symbol}}
-
- - Test - + + + + + + + + + + + + + + + + + + + + +
No.ItemQuantityCost
{{i + 1}}{{item.item}}{{item.quantity}}{{item.price | currency}} + delete +
+
+ + + + + +
+ Sub Total: + {{total() | currency}}
+
+
\ No newline at end of file diff --git a/src/app/store/cart/cart.component.ts b/src/app/store/cart/cart.component.ts index b529a7b..29f59fd 100644 --- a/src/app/store/cart/cart.component.ts +++ b/src/app/store/cart/cart.component.ts @@ -1,14 +1,30 @@ import {Component} from '@angular/core'; import {LocalStorage} from 'webstorage-decorators'; +import {access} from 'fs'; @Component({ - selector: 'cart', - templateUrl: 'cart.component.html' + selector: 'cart', + templateUrl: 'cart.component.html' }) export class CartComponent { - @LocalStorage({defaultValue: []}) cart: {id: string, name: string, cost: number, quantity: number}[]; + @LocalStorage({defaultValue: []}) + cart: {id: string; item: string; price: number; quantity: number}[]; - constructor() { + address1: string; + address2: string; + city: string; + province: string; + postal: string; - } -} \ No newline at end of file + constructor() {} + + remove(i: number) { + let c = this.cart; + c.splice(i, 1); + this.cart = c; + } + + total() { + return this.cart.reduce((acc, row) => acc + row.price * row.quantity, 0); + } +}