angular submit button on submit code example

Example 1: angular submit form programmatically

// html
<form ngNoForm
    [formGroup]="testGroup"
    [action]='actionLink'
    method='POST'
    #testForm>
	<input name='Email' type='hidden' [value]='currentUserEmail'>
</form>
// ts
@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

// type button required otherwise it will submit the form 
<button type="button" (click)="preview();">Preview</button>