How to have a button in form in Angular 7 which doesn't bubble a submit event?In Angular 2, how do I submit an input type=“text” value upon pressing enter?Angular 2 prevent enter from submitting in template-driven formAngular2 Model Driven From Not Firing ngSubmitHow to fire all validation without disabling submit button in angular (v4)?Submit a form from a grand-parent component with Angulartriggering the ngSubmit about mat-select box checkboxesHow to know if an Angular (v5) Reactive-Form is submitted from a form field which itself is a custom component?Angular Two buttons to submit a form but with different purposeAngular Form does not submit on enter when not focusedValidate child component form when a parent component button is clicked in Angular

IndexOptimize - Configuration

Why is my Earth simulation slower than the reality?

How do I find the fastest route from Heathrow to an address in London using all forms of transport?

Can I switch to third-person while not in 'town' in Destiny 2?

confused about grep and the * wildcard

Why did this happen to Thanos's ships at the end of "Avengers: Endgame"?

Is it appropriate for a prospective landlord to ask me for my credit report?

Solve a logarithmic equation by NSolve

In what ways can a Non-paladin access Paladin spells?

Do ability scores have any effect on casting Wish spell

How do I make distance between concentric circles equal?

Was Tuvok bluffing when he said that Voyager's transporters rendered the Kazon weapons useless?

How much code would a codegolf golf if a codegolf could golf code?

Does an object count as "being moved" when placed in a Bag of Holding before its wielder moves, and then after moving they take the object out again?

Which household object drew this pattern?

Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")

How would one country purchase another?

How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?

Why we don't have vaccination against all diseases which are caused by microbes?

How to avoid using System.String with Rfc2898DeriveBytes in C#

If the first law of thermodynamics ensures conservation of energy, why does it allow systems to lose energy?

Is refusing to concede in the face of an unstoppable Nexus combo punishable?

Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?

If I have a 16.67% fail rate (N=24) & I do another 24 tests, what is the likelihood that I get 0 fails by chance?



How to have a button in form in Angular 7 which doesn't bubble a submit event?


In Angular 2, how do I submit an input type=“text” value upon pressing enter?Angular 2 prevent enter from submitting in template-driven formAngular2 Model Driven From Not Firing ngSubmitHow to fire all validation without disabling submit button in angular (v4)?Submit a form from a grand-parent component with Angulartriggering the ngSubmit about mat-select box checkboxesHow to know if an Angular (v5) Reactive-Form is submitted from a form field which itself is a custom component?Angular Two buttons to submit a form but with different purposeAngular Form does not submit on enter when not focusedValidate child component form when a parent component button is clicked in Angular






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a button in an Angular 7 form which is only supposed to toggle advanced form options. It works for that but it is also getting caught by my form object and NgForm is running the function which is only supposed to run when the submit button is pressed.



I'm using template driven approach. I'll show here my form element and the button that shouldn't be submitting.



<form (ngSubmit)="onSubmit(form)" #form="ngForm">


break



<button 
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>


Is there any way to specify to Angular that this is not a submit button?










share|improve this question



















  • 2





    Default type for a button is submit MDN docs. What happens when you change the type to button?

    – peinearydevelopment
    Mar 27 at 16:04

















0















I have a button in an Angular 7 form which is only supposed to toggle advanced form options. It works for that but it is also getting caught by my form object and NgForm is running the function which is only supposed to run when the submit button is pressed.



I'm using template driven approach. I'll show here my form element and the button that shouldn't be submitting.



<form (ngSubmit)="onSubmit(form)" #form="ngForm">


break



<button 
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>


Is there any way to specify to Angular that this is not a submit button?










share|improve this question



















  • 2





    Default type for a button is submit MDN docs. What happens when you change the type to button?

    – peinearydevelopment
    Mar 27 at 16:04













0












0








0








I have a button in an Angular 7 form which is only supposed to toggle advanced form options. It works for that but it is also getting caught by my form object and NgForm is running the function which is only supposed to run when the submit button is pressed.



I'm using template driven approach. I'll show here my form element and the button that shouldn't be submitting.



<form (ngSubmit)="onSubmit(form)" #form="ngForm">


break



<button 
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>


Is there any way to specify to Angular that this is not a submit button?










share|improve this question














I have a button in an Angular 7 form which is only supposed to toggle advanced form options. It works for that but it is also getting caught by my form object and NgForm is running the function which is only supposed to run when the submit button is pressed.



I'm using template driven approach. I'll show here my form element and the button that shouldn't be submitting.



<form (ngSubmit)="onSubmit(form)" #form="ngForm">


break



<button 
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>


Is there any way to specify to Angular that this is not a submit button?







angular






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 16:01









rook218rook218

54 bronze badges




54 bronze badges










  • 2





    Default type for a button is submit MDN docs. What happens when you change the type to button?

    – peinearydevelopment
    Mar 27 at 16:04












  • 2





    Default type for a button is submit MDN docs. What happens when you change the type to button?

    – peinearydevelopment
    Mar 27 at 16:04







2




2





Default type for a button is submit MDN docs. What happens when you change the type to button?

– peinearydevelopment
Mar 27 at 16:04





Default type for a button is submit MDN docs. What happens when you change the type to button?

– peinearydevelopment
Mar 27 at 16:04












1 Answer
1






active

oldest

votes


















1













You need to set the button type to 'button' as the default type attribute for a button is 'submit'.



<button 
type="button"
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>





share|improve this answer



























  • That did the trick! Thanks.

    – rook218
    Mar 27 at 16:32










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381646%2fhow-to-have-a-button-in-form-in-angular-7-which-doesnt-bubble-a-submit-event%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1













You need to set the button type to 'button' as the default type attribute for a button is 'submit'.



<button 
type="button"
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>





share|improve this answer



























  • That did the trick! Thanks.

    – rook218
    Mar 27 at 16:32















1













You need to set the button type to 'button' as the default type attribute for a button is 'submit'.



<button 
type="button"
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>





share|improve this answer



























  • That did the trick! Thanks.

    – rook218
    Mar 27 at 16:32













1












1








1







You need to set the button type to 'button' as the default type attribute for a button is 'submit'.



<button 
type="button"
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>





share|improve this answer















You need to set the button type to 'button' as the default type attribute for a button is 'submit'.



<button 
type="button"
class="btn btn-success"
(click)="onDisplayOptions()">
Toggle more options
</button>






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 27 at 16:26

























answered Mar 27 at 16:10









Jack_b_321Jack_b_321

2211 silver badge11 bronze badges




2211 silver badge11 bronze badges















  • That did the trick! Thanks.

    – rook218
    Mar 27 at 16:32

















  • That did the trick! Thanks.

    – rook218
    Mar 27 at 16:32
















That did the trick! Thanks.

– rook218
Mar 27 at 16:32





That did the trick! Thanks.

– rook218
Mar 27 at 16:32








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381646%2fhow-to-have-a-button-in-form-in-angular-7-which-doesnt-bubble-a-submit-event%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript