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(); } }