Skip to main content


Showing posts from April, 2020

How to submit a form in Angular?

In Angular, you can submit a form using the (ngSubmit) directive. Here's an example: First, create a form in your template using the ngForm directive: <form # myForm= "ngForm" ( ngSubmit )=" onSubmit ( myForm )" > <label for= "name" > Name: </label> <input type= "text" id= "name" name= "name" ngModel > <label for= "email" > Email: </label> <input type= "email" id= "email" name= "email" ngModel > <button type= "submit" > Submit </button> </form> In this example, we're using the ngForm directive to create a form and binding it to a template reference variable #myForm. We're also using the ngModel directive to bind the input fields to properties in our component. Next, we're using the (ngSubmit) directive to call a function called onSubmit() w