import { Component, OnInit } from '@angular/core'; import { CartService } from '../../shared/services/cart.service'; import { Observable, of } from 'rxjs'; import { CartItem } from 'src/app/modals/cart-item'; import { ProductService } from '../../shared/services/product.service'; @Component({ selector: 'app-checkout', templateUrl: './checkout.component.html', styleUrls: ['./checkout.component.sass'] }) export class CheckoutComponent implements OnInit { public cartItems: Observable<CartItem[]> = of([]); public buyProducts: CartItem[] = []; amount: number; payments: string[] = ['Create an Account?', 'Flat Rate']; paymantWay: string[] = ['Direct Bank Transfer', 'PayPal']; constructor(private cartService: CartService, public productService: ProductService) { } ngOnInit() { this.cartItems = this.cartService.getItems(); this.cartItems.subscribe(products => this.buyProducts = products); this.getTotal().subscribe(amount => this.amount = amount); } public getTotal(): Observable<number> { return this.cartService.getTotalAmount(); } }