0

I'm trying to clear the form, but keep facing some issues. How can I clear the form on a submit?

HTML

<form id="contact" class="contact-form" ng-submit="sendMail()" novalidate ng-controller="QuoteCtrl">
<div class="message"></div>
 <div class="col-md-5 col-sm-5 col-xs-12 animated hiding" data-animation="slideInLeft">
  <div class="form-group">
    <input type="text" name="name" class="nameform form-control input-lg" placeholder="name" ng-model="message.contactName" required>
  </div>     
</div>

<div class="col-md-7 col-sm-7 col-xs-12">
    <input type="submit" class="btn btn-custom up form-button" value="Send Message">

Angular

app.controller('QuoteCtrl', ['$scope', '$interval', '$http', 
function($scope, $interval, $http) {
    $scope.message = {};
   $scope.sendMail = function () {
      $http.post('/send/sendQuote', $scope.message).
        success(function(data) {
         $scope.message = data.message;
         console.log($scope.message);
         $scope.message = {};
      });
   }
}]);

What are the main techniques to clear forms, including setPrestine()?

1 Answer 1

1

try it.it will work fine

$http.post('/send/sendQuote', $scope.message).
        success(function(data) {
         $scope.message = data.message;
         console.log($scope.message);
         $scope.message.contactName=null;
      });
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, it didn't work for me. Is there any other ways?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.