Maureen Moore

Maureen Moore

  • NA
  • 206
  • 0

Button click event submits the quantity

Jul 20 2020 3:41 PM
This question is related to another question that I asked recently at the forum. I had to start a new post because my question evolved over time and my original question wasn't valid any more. I narrowed down my problem to the quantity buttons submitting every time they're clicked so I am only showing my quantity button code. What I want to find out is how can I get the buttons to only submit when the submit button is clicked. Right now they console log 'click submitted' every time they are clicked.
The HTML
  1. <button class="minus-btn" (click)="minus(product)" type="button" name="btn" onclick="return false;">  
  2. <img src="../assets/images/minus.svg" alt="minus" /></button>  
  3. <input class="num" name="int" [value]="product.nullValue" formControlName="int" ng-minlength="0" type="number" required />  
  4. <button class="plus-btn" (click)="plus($event, product)" name="btn" type="button" onclick="return false;">  
  5. <img src="../assets/images/plus.svg" alt="plus" /></button>  
and in the controller:
  1. plus($event, product:any) {  
  2. $event.preventDefault();  
  3. product.nullValue++;  
  4. this.quantity = product.nullValue;  
  5. console.log('click submitted');  
  6. return false;  
  7. return this.quantity;  
  8. }  
  9.   
  10. minus(product:any){  
  11. product.nullValue--;  
  12. this.quantity = product.nullValue;  
  13. console.log('click submitted');  
  14. return false;  
  15. return this.quantity;  
  16.   
  17. }  

Answers (2)