How do I reset a form including removing all validation errors?

前端 未结 10 824
梦毁少年i
梦毁少年i 2020-12-14 01:59

I have an Angular form. The fields are validated using the ng-pattern attribute. I also have a reset button. I\'m using the Ui.Utils Event Binder to handle the

10条回答
  •  囚心锁ツ
    2020-12-14 02:38

    You can pass your loginForm object into the function ng-click="userCtrl.login(loginForm) and in the function call

    this.login = function (loginForm){
      loginForm.$setPristine();
      loginForm.$setUntouched();
    }
    

提交回复
热议问题