I am facing an issue where I want to implement functionality to modify the quantity of a selected product using two buttons: minus and plus. Strangely, when clicking the plus button it also triggers the click event of the minus button. Can anyone shed light on why this might be happening? Appreciate your help!
let productQuantity = 1;
constructor() { }
ngOnInit(): void {
this.modifyProductQuantity();
}
modifyProductQuantity(){
let decreaseBtn = document.querySelector('#minus') as HTMLElement;
let increaseBtn = document.querySelector('#plus') as HTMLElement;
decreaseBtn.onclick = () => {
if(productQuantity > 1){
productQuantity--;
}
};
increaseBtn.onclick = () => {
productQuantity++;
};
}