TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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
<
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;
}
Reply
Answers (
2
)
Trying to sum up the grandTotal doesn't work
Routing in Angular 1.x