angular - FEIL TypeError: _co.shoppingCart.getQuantity er ikke en funksjon


Jeg jobber på et Angular5-prosjekt, og jeg bruker en funksjon getQuantity i to forskjellige maler.

I malen nedenfor "product-card", forårsaker getQuantity feilen.

ProductCardComponent.html:8 ERROR TypeError: _co.shoppingCart.getQuantity is not a function

Mens det i en annen mal "product-quantity" fungerer det fint.

<div *ngIf="showActions && shoppingCart" class="card-footer">
    <button *ngIf="shoppingCart.getQuantity(product) === 0; else updateQuantity"
    (click)="addToCart()" class="btn btn-secondary btn-block">Add to Cart</button>
    <ng-template #updateQuantity>
      <app-product-quantity [product]="product"
      [shopping-cart]="shoppingCart"></app-product-quantity>
    </ng-template>
</div>

Nedenfor er min ProductCardComponent-komponent:

import { ShoppingCart } from './../models/shopping-cart';
import { Product } from './../models/product';
import { Component, OnInit, Input } from '@angular/core';
import { ShoppingCartService } from '../shopping-cart.service';

@Component({
  selector: 'app-product-card',
  templateUrl: './product-card.component.html',
  styleUrls: ['./product-card.component.css']
})
export class ProductCardComponent {
  @Input('product') product: Product;
  @Input('show-actions') showActions = true;
  @Input('shopping-cart') shoppingCart: ShoppingCart;

  constructor(private cartService: ShoppingCartService) { }

  addToCart() {
    this.cartService.addToCart(this.product);
  }
}

Dette er min hjelpeklasse der metoden getQuantity er til stede:

import { ShoppingCartItem } from './shopping-cart-item';
import { Product } from './product';

export class ShoppingCart {
    items: ShoppingCartItem[] = [];
    constructor(public itemsMap: { [productId: string]: ShoppingCartItem }) {
        for (const productId in itemsMap) {
            if (productId) {
                const item = itemsMap[productId];
                if (item) {
                    this.items.push(new ShoppingCartItem(item.product, item.quantity));
                }
            }
        }
    }

    getQuantity(product: Product) {
        const item = this.itemsMap[product.key];
        return item ? item.quantity : 0;
    }

   // other methods here
}

Jeg klarer ikke å finne ut hvorfor jeg får denne feilen. Jeg trenger veiledningen din. Takk på forhånd.