I created 2 components, one with products and one with shopping cart... They communicate through a service. Each time I add a product, this product is replaced by the new one ... Technically I would like to "push" the product in an array of products
cart: Product[];
product : Product;
subscription : Subscription;
constructor(private basketdataService: BasketdataService) {
this.subscription = this.basketdataService.onGetBasket().subscribe(
product => {
this.product = product;
});
console.log("résultat");
}
In fact, I wonder how I can push data in this array, avoiding to make it empty at each event.
cartarray in thethenstatement. I don't see any problem here!