Resetting form after submit in Angularjs

This worked for me.

viewModel.data = {};
$scope.formName.$setUntouched();
$scope.formName.$setPristine();

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


You can reset a form by, $scope.formName.$setPristine(); but if you're binding a model object to your inputs, you need to take care of clearing those too, ie:

$scope.currentRecord={};

EDIT

As ToodoN-Mike pointed out, don't forget to set

$scope.formName.$setUntouched()

The $touched flag was introduced in angular 1.3.