2016-09-28 106 views
2

填写表单提交按钮的所有必填字段后启用。Angular Js清除表单

当我清除表单时,所有日期都清除但提交按钮仍然启用。

这里是myForm的:

**<form id="payment-form" name="creditPaymentForm"> 
    <input type="text" ng-model="cardcno" ng-minlength="15" required=""> 
    <input type="text" ng-model="cardcvv" ng-minlength="3" required=""> 
    <input type="text" ng-model="cardexp" ng-minlength="6" required=""> 
    <button type="submit" ng-click="submitForm()" ng-disabled="creditPaymentForm.$invalid">Submit</button>** 
    <button type="reset" ng-click="creditPaymentForm.$setPristine();">Clear</button> 
</form> 
+0

从ng上单击清除'$ scope'清除 – nmanikiran

+0

试过,仍然有效。 –

回答

1

Workine对我很好

我也intialize控制器值这样

$scope.cardcno = ""; 
    $scope.cardcvv = ""; 
    $scope.cardexp = ""; 

这里是工作提琴:

JSFIDDLE

+0

你是对的,我们不应该使用'$ scope.creditPaymentForm = {}; ',它使完整的对象变为空 –