angular submit button on submit code example
Example 1: angular submit form programmatically
<form ngNoForm
[formGroup]="testGroup"
[action]='actionLink'
method='POST'
#testForm>
<input name='Email' type='hidden' [value]='currentUserEmail'>
</form>
@ViewChild('testForm') testFormElement;
public currentUserEmail: string = '';
public testGroup = this.formBuilder.group({
Email: ''
});
public testMethod(): void
{
this.testFormElement.nativeElement.submit();
}
Example 2: click on button submitting the form in angular
<button type="button" (click)="preview();">Preview</button>