Angular - Submit a form programmatically

后端 未结 5 656
深忆病人
深忆病人 2021-02-07 02:40

Angular - Submit a form programmatically.

I have a form group on the HTML and I want the component to submit the form\'s action with an email field in a post method. Ins

5条回答
  •  北海茫月
    2021-02-07 03:23

    I have found a good solution on github

    it will setup submitted as true

    Out approach now is:

    HTML:

     

    ts:

    @ViewChild('myForm') ngForm: NgForm;
    
    ...
    public onSubmit() {
     this.ngForm.onSubmit(undefined); // it will setup submitted as true
    

提交回复
热议问题