This commit is contained in:
PLAINCONCEPTS\lruiz 2017-08-23 11:06:50 +02:00
parent a6acdabf85
commit 8d14869ca0
2 changed files with 26 additions and 14 deletions

View File

@ -25,7 +25,8 @@
<section class="esh-basket-item esh-basket-item--middle col-xs-3">{{item.productName}}</section> <section class="esh-basket-item esh-basket-item--middle col-xs-3">{{item.productName}}</section>
<section class="esh-basket-item esh-basket-item--middle col-xs-2">$ {{item.unitPrice | number:'.2-2'}}</section> <section class="esh-basket-item esh-basket-item--middle col-xs-2">$ {{item.unitPrice | number:'.2-2'}}</section>
<section class="esh-basket-item esh-basket-item--middle col-xs-2"> <section class="esh-basket-item esh-basket-item--middle col-xs-2">
<input class="esh-basket-input" <input id="quantity"
class="esh-basket-input"
type="number" type="number"
min="1" min="1"
[(ngModel)]="item.quantity" [(ngModel)]="item.quantity"

View File

@ -34,16 +34,27 @@ export class BasketComponent implements OnInit {
this.service.setBasket(this.basket).subscribe(x => console.log('basket updated: ' + x)); this.service.setBasket(this.basket).subscribe(x => console.log('basket updated: ' + x));
} }
update(event: any) { update(event: any): Observable<boolean> {
this.service.setBasket(this.basket).catch((errMessage) => { let setBasketObservable = this.service.setBasket(this.basket);
this.errorMessages = errMessage.messages; setBasketObservable
return Observable.throw(errMessage); .subscribe(
}).subscribe(x => console.log('basket updated: ' + x)); x => {
this.errorMessages = [];
console.log('basket updated: ' + x);
},
errMessage => this.errorMessages = errMessage.messages);
return setBasketObservable;
} }
checkOut(event: any) { checkOut(event: any) {
this.update(event)
.subscribe(
x => {
this.errorMessages = [];
this.basketwrapper.basket = this.basket; this.basketwrapper.basket = this.basket;
this.router.navigate(['order']); this.router.navigate(['order'],
errMessage => this.errorMessages = errMessage.messages);
});
} }
private calculateTotalPrice() { private calculateTotalPrice() {