Resetting form after submit in Angularjs

后端 未结 5 1222
情话喂你
情话喂你 2020-11-29 07:57

Hi I have a form which does update on button click.

 $scope.action = \"Update\";
  var id = $routeParams.editId;
  scope.item = updateRecord.get({ id: id })         


        
5条回答
  •  情深已故
    2020-11-29 08:28

    At the bottom of your submit function's body run this code below.

    // Reset the form model.
    vm.project = {};
    // Set back to pristine.
    vm.form.$setPristine();
    // Since Angular 1.3, set back to untouched state.
    vm.form.$setUntouched();
    

    "vm.form" is my form name.

    For more info have a look at this docs page: https://docs.angularjs.org/api/ng/type/form.FormController

提交回复
热议问题