I have created template driven form in Angular.
<form novalidate #f="ngForm" (ngSubmit)="onSubmit(f)">
<input type="text" class="form-control" name="fullName" #fullName="ngModel" required>
<div *ngIf="fullName.errors?.required && fullName.touched" class="validation-message">Required</div>
<button type="submit">Post</button>
It shows error when it is invalid and touched. I need to display error when form is submitted i.e. when the submit button is clicked.
onSubmit({value, valid}): void {
if (valid) {
console.log(value);
} else {
console.log('invalid form');
}
}