Urban Bazaar with proxy servers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

84 lines
1.8 KiB

import { HttpClient } from '@angular/common/http';
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { Cart } from '../models/cart';
@Injectable({
providedIn: 'root'
})
export class CartService {
private _url : String = "http://localhost:8004/cart";
constructor(private _http : HttpClient) { }
public addCartItem(item:Cart)
{
this._http.post(this._url+"/addCartItem",item);
// console.log(item);
}
public showCart():Observable<Cart[]>
{
return this._http.get<Cart[]>(this._url+"/showCart");
}
// public cartListItem: any=[]
// public productList = new BehaviorSubject<any>([])
// public addOrder(cart:Cart)
// {
// this._http.post(this._url+"/addCart",cart)
// }
// getProducts()
// {
// return this.productList.asObservable();
// }
// setProduct(product:any)
// {
// this.cartListItem.push(...product);
// this.productList.next(product);
// }
// addtoCart(product:any)
// {
// this.cartListItem.push(product);
// this.productList.next(this.cartListItem)
// this.getTotalPrice();
// // console.log(this.cartListItem);
// }
// getTotalPrice():number{
// let grandTotal=0;
// this.cartListItem.map((a:any)=>{
// grandTotal+=a.productprice;
// })
// return grandTotal;
// }
// removeCartItem(product:any)
// {
// this.cartListItem.map((a:any,index:any)=>{
// if(product.productid === a.productid)
// {
// this.cartListItem.splice(index,1);
// }
// })
// this.productList.next(this.cartListItem);
// }
// removeAllCart()
// {
// this.cartListItem=[]
// this.productList.next(this.cartListItem);
// }
}