title: How to reset form fields in angular js after form submit
body: <p>I am submitting form using angular js.
  I want to <strong>reset form fields after submit</strong>.</p>
  
  <p><strong>DEMO_ANGULAR JS</strong></p>
  
  <pre><code>   $scope.addUser = function() 
      {
          $scope.errors = [];
          $scope.msgs = [];
  
          $scope.errors.splice(0, $scope.errors.length); // remove all error messages
          $scope.msgs.splice(0, $scope.msgs.length);
  
          $http.post("../admin/users/add_user", {'fname': $scope.fname, 'lname': $scope.lname, 'uname': $scope.uname,'gender': $scope.gender,'email': $scope.email,'mobile': $scope.mobile,'pass': $scope.pass}
          ).success(function(data, status, headers, config) {
  
              if (data.msg != '')
              {
                  $scope.msgs.push(data.msg);
                  $scope.get_users();
                  $scope.form_add.$setPristine();
                  $scope.currentRecord={};
              }
              else
              {
                  $scope.errors.push(data.error);
              }
          }).error(function(data, status) { // called asynchronously if an error occurs
  // or server returns response with an error status.
              $scope.errors.push(status);
          });
      }
  </code></pre>
  
  <p><strong>And This is my view (HTML) form for add user:</strong></p>
  
  <pre><code>&lt;form name="form_add" method="post"&gt;
                       &lt;ul&gt;
                          &lt;li style="color:red" ng-repeat="error in errors"&gt; {{ error}} &lt;/li&gt;
                      &lt;/ul&gt;
                      &lt;ul&gt;
                          &lt;li style="color:green" ng-repeat="msg in msgs"&gt; {{ msg}} &lt;/li&gt;
                      &lt;/ul&gt;
                          &lt;table class="table" cellspacing=10 cellpadding=10&gt;
                          &lt;tr&gt;
                          &lt;td&gt;First Name: &lt;input required type="text" ng-pattern="/[a-zA-Z]$/"  ng-model="fname"  name="fname" id="fname" value=""/&gt;&lt;br/&gt;
                          &lt;span style="color:red" ng-show="form_add.fname.$dirty &amp;&amp; form_add.fname.$invalid"&gt;
                                  &lt;span ng-show="form_add.fname.$error.required"&gt;First Name is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.fname.$error.pattern"&gt;Invalid&lt;/span&gt;
                          &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;Last Name: &lt;input required type="text" ng-pattern="/[a-zA-Z]$/" ng-model="lname" name="lname" id="lname" value=""/&gt;&lt;br/&gt;
                          &lt;span style="color:red" ng-show="form_add.lname.$dirty &amp;&amp; form_add.lname.$invalid"&gt;
                                  &lt;span ng-show="form_add.lname.$error.required"&gt;Last Name is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.lname.$error.pattern"&gt;Invalid&lt;/span&gt;
                          &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;User Name: &lt;input required type="text" ng-pattern="/^[a-zA-Z0-9]{6,15}$/"   ng-model="uname" name="uname" id="uname" value=""/&gt;&lt;br/&gt;
                          &lt;span style="color:red" ng-show="form_add.uname.$dirty &amp;&amp; form_add.uname.$invalid"&gt;
                                  &lt;span ng-show="form_add.uname.$error.required"&gt;User Name is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.uname.$error.pattern"&gt;Invalid: Minimum 6 characters and maximum 15 characters&lt;/span&gt;    
                          &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td width="20%"&gt;Gender :&lt;br/&gt; &lt;input type="radio"  ng-model="gender" name="gender" id="r1" value="m" checked /&gt;Male
                          &amp;nbsp;&amp;nbsp;&lt;input type="radio"  ng-model="gender" name="gender" id="r2" value="f"/&gt;Female&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                          &lt;td&gt;Email ID: &lt;input type="text" required ng-pattern="/^[a-z]+[a-z0-9._]+@[a-z]+\.[a-z.]{2,5}$/"  ng-model="email" name="email" id="email" value=""/&gt;&lt;br/&gt;
                              &lt;span style="color:red" ng-show="form_add.email.$dirty &amp;&amp; form_add.email.$invalid"&gt;
                                  &lt;span ng-show="form_add.email.$error.required"&gt;Email is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.email.$error.pattern"&gt;Invalid email address.&lt;/span&gt;
                              &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;Mobile : &lt;input type="text" required  ng-model="mobile" ng-pattern="/^[1-9]{1}[0-9]{9}$/"  name="mobile" id="mobile" value=""/&gt;&lt;br/&gt;
                          &lt;span style="color:red" ng-show="form_add.mobile.$dirty &amp;&amp; form_add.mobile.$invalid"&gt;
                                  &lt;span ng-show="form_add.mobile.$error.required"&gt;Mobile is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.mobile.$error.pattern"&gt;10 digits required&lt;/span&gt;
                          &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;Password : &lt;input required type="password" ng-model="pass" name="pass" id="pass" value=""/&gt;
                          &lt;span style="color:red" ng-show="form_add.mobile.$dirty &amp;&amp; form_add.mobile.$invalid"&gt;
                                  &lt;span ng-show="form_add.mobile.$error.required"&gt;Mobile is required.&lt;/span&gt;
                                  &lt;span ng-show="form_add.mobile.$error.pattern"&gt;10 digits required&lt;/span&gt;
                          &lt;/span&gt;
                          &lt;/td&gt;
                          &lt;td&gt;&lt;button type="button" class="btn btn-primary" ng-click='addUser();' ng-disabled="form_add.$invalid"&gt;Save&lt;/button&gt;&lt;/td&gt;
                          &lt;/tr&gt;
  
                          &lt;/table&gt;
  
                      &lt;br/&gt;
                      &lt;/form&gt;
  </code></pre>
  
  <p>How to reset form after submit, any changes in above code?
  <strong>And my issue is not solved yet!</strong></p>