提交后清除 Angular 表格
Clear an Angular form upon Submission
我正在尝试清除表格,但仍然遇到一些问题。如何清除提交时的表单?
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 = {};
});
}
}]);
包括setPrestine()在内的清除表格的主要技巧有哪些?
试试 it.it 会很好
$http.post('/send/sendQuote', $scope.message).
success(function(data) {
$scope.message = data.message;
console.log($scope.message);
$scope.message.contactName=null;
});
我正在尝试清除表格,但仍然遇到一些问题。如何清除提交时的表单?
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 = {};
});
}
}]);
包括setPrestine()在内的清除表格的主要技巧有哪些?
试试 it.it 会很好
$http.post('/send/sendQuote', $scope.message).
success(function(data) {
$scope.message = data.message;
console.log($scope.message);
$scope.message.contactName=null;
});