Is it bad practice to replace (ngSubmit) with a (click) handler in an Angular form?

Discussão em 'Angular' iniciado por maxime Lassort, Junho 19, 2025.

  1. I’m working on an Angular application and I’ve seen some developers avoid using (ngSubmit) on forms. Instead, they just add a (click) handler to the submit button, like this:

    <form>
    <!-- form fields -->
    <button (click)="onSubmit()">Submit</button>
    </form>


    instead of a more typical approach :

    <form (ngSubmit)="onSubmit()" #form="ngForm">
    <!-- form fields -->
    <button type="submit">Submit</button>
    </form>

    My questions:


    • Is it considered bad practice to use a (click) handler instead of (ngSubmit) on a form?


    • What are the downsides of doing so (validation, accessibility, native behavior, etc.)?


    • Are there any valid scenarios where using (click) instead of (ngSubmit) makes sense?

    It works either way, but I feel like using (click) might bypass Angular’s built-in validation and form behavior. I'd love to get some expert input on this.

    Thanks!

    Continue reading...

Compartilhe esta Página