Click submit and console.log hello world
<form (ngSubmit)="onSubmit()">
<div id="user-data">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" ngModel name="username">
</div>
</div>
<button type="submit">Submit</button>
</form>
onSubmit(){
console.log('Hello World!');
}
Get form’s data
onSubmit(form: ElementRef){
console.log(form);
}
HTML
<form (ngSubmit)="onSubmit(f)" #f="ngForm">
<div id="user-data">
<div class="form-group">
<label for="username">Username</label>
<input
type="text"
id="username"
class="form-control"
ngModel
name="username">
</div>
<div class="form-group">
<label for="email">Mail</label>
<input
type="email"
id="email"
class="form-control"
ngModel
name="email">
</div>
</div>
<button type="submit">Submit</button>
</form>
