Closed dcharua closed 5 years ago
There seem to be many solutions to this problem, I ended up implementing the simplest one, avoiding the resubscription my checking if already subscribed, like this
if(this.globalService.newlineItemObs.observers.length == 0) { this.globalService.newlineItemObs.subscribe(lineItem => { if (lineItem) { console.log("new line item"); this.addItem(lineItem); } }) }
Hi, there seems to be an issue with the cart in the angular app. Every time you navigate to another route and go back to the cart all the lineitems are added again and duplicate the existing ones. This line of code is triggered twice with the lineItem in NgOnInit cart.component, then three times if you navigate out and in again
I tried to unsubnscribe onDestroy() it does not duplicate items any more but than i can not add new items to the cart.
any ideas? Thank you