I want to modify the quantity of the selected product with 2 buttons: minus and plus. Clicking the minus button works as expected but clicking the plus button also triggers the minus buttons' click event.
Any idea why? Thank you!
productQuantity = 1;
constructor() { }
ngOnInit(): void {
this.modifyQuantity();
}
modifyQuantity(){
let minusBtn = document.querySelector('#minus') as HTMLElement;
let plusBtn = document.querySelector('#plus') as HTMLElement;
minusBtn.onclick = () => {
if(this.productQuantity > 1){
this.productQuantity--;
}
};
plusBtn.onclick = () => {
this.productQuantity++;
};
}