Online Grocery Shop
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.
 
 
 
 
 

36 lines
851 B

import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Cart } from 'src/app/models/cart';
import { CartService } from 'src/app/services/cart.service';
@Component({
selector: 'app-cart',
templateUrl: './cart.component.html',
styleUrls: ['./cart.component.css']
})
export class CartComponent implements OnInit {
public cartdetails:any =[];
public grandTotal!: number;
constructor(private cartservice:CartService) {
// this.cartdetails = this.cartservice.showAllOrder();
}
ngOnInit(): void {
this.cartservice.getProducts()
.subscribe(res=>{
this.cartdetails = res;
this.grandTotal = this.cartservice.getTotalPrice();
})
}
removeItem(item:any){
this.cartservice.removeCartItem(item);
}
emptyCart()
{
this.cartservice.removeAllCart();
}
}