In Angular, how can you prevent the default form submission behavior of a page reload?

  • Set action="javascript:void(0)"
  • Use (click)="preventDefault()"
  • Use (ngSubmit)="onSubmit($event)"
  • Use (submit)="preventDefault()"
To prevent the default form submission behavior of a page reload in Angular, you should use (ngSubmit)="onSubmit($event)" and handle the form submission in your component.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *