2016-09-28 103 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 = {}; ',它使完整的對象變爲空 –