Reputation: 55
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()?
Upvotes: 0
Views: 47
Reputation: 407
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;
});
Upvotes: 1