Saturday, June 9, 2018

Reset form in ionic 2 | ionic 3 in ionic 2 | ionic 3 | ionic 4 | angular2 | angular4

First add below code in your TS file :


import { Component} from ‘@angular/core’;

import { FormBuilder, FormGroup } from ‘@angular/forms’;


export class YourPage {

  public commentForm  : FormGroup;

  constructor(public _FB: FormBuilder) {

           this.commentForm  = _FB.group({

           comment: Validator.feedCreateValidator

      });

   }

  resetForm()
  {
      this.commentForm.reset();
  }



}

Note : Just call “resetForm()” method from your template. It will reset your form.

This will reset your form data.

No comments:

Post a Comment