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
- <button class="minus-btn" (click)="minus(product)" type="button" name="btn" onclick="return false;">
- <img src="../assets/images/minus.svg" alt="minus" /></button>
- <input class="num" name="int" [value]="product.nullValue" formControlName="int" ng-minlength="0" type="number" required />
- <button class="plus-btn" (click)="plus($event, product)" name="btn" type="button" onclick="return false;">
- <img src="../assets/images/plus.svg" alt="plus" /></button>
and in the controller:
- plus($event, product:any) {
- $event.preventDefault();
- product.nullValue++;
- this.quantity = product.nullValue;
- console.log('click submitted');
- return false;
- return this.quantity;
- }
-
- minus(product:any){
- product.nullValue--;
- this.quantity = product.nullValue;
- console.log('click submitted');
- return false;
- return this.quantity;
-
- }