Can a form be submitted using ViewChild in Angular5? If so, how can it be achieved?
I attempted to do this but was unsuccessful
My Attempt:
<form #form="ngForm" (submit)="submitForm(form)" novalidate>
<input required type="text" #codeRequest="ngModel" [(ngModel)]="requestModel.codeRequest" id="codeRequest" name="codeRequest"/>
</form>
<button (click)="func()"> </button>
Code Snippet :
@ViewChild('form') form: ElementRef;
constructor(){}
func(){
this.formStep2.nativeElement.submit();
}
submitForm(form: NgForm) {
...
}
What might be causing my issue?