import { Component, OnInit } from '@angular/core'; import { CartService } from 'src/app/service/cart.service'; @Component({ selector: 'app-cart', templateUrl: './cart.component.html', styleUrls: ['./cart.component.css'] }) export class CartComponent implements OnInit { cartNo:number = 0; uid:string = "10"; constructor(private cartService:CartService) { } ngOnInit(): void { this.cartService.getCartByUser(this.uid).subscribe(data1 => { this.cartNo = data1.length; }) } }