Answers for "form submit in angular"

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();
}
Posted by: Guest on May-14-2020
1

ngForm

<form #f="ngForm" (ngSubmit)="onSubmit(f)" novalidate>
  <input name="first" ngModel required #first="ngModel">
  <input name="last" ngModel>
  <button>Submit</button>
</form>

<p>First name value: {{ first.value }}</p>
<p>First name valid: {{ first.valid }}</p>
<p>Form value: {{ f.value | json }}</p>
<p>Form valid: {{ f.valid }}</p>
Posted by: Guest on September-17-2020
1

click on button submitting the form in angular

// type button required otherwise it will submit the form 
<button type="button" (click)="preview();">Preview</button>
Posted by: Guest on August-18-2020

Browse Popular Code Answers by Language