4
我有一個表單,我在輸入上使用了required tag
- 這工作正常,但在提交按鈕上我有ng-click="visible = false"
,當數據提交時隱藏表單。Angular JS HTML5驗證
我該如何使它只有在所有驗證都正確的情況下設置爲false?
App.js
$scope.newBirthday = function(){
$scope.bdays.push({name:$scope.bdayname, date:$scope.bdaydate});
$scope.bdayname = '';
$scope.bdaydate = '';
};
HTML:
<form name="birthdayAdd" ng-show="visible" ng-submit="newBirthday()">
<label>Name:</label>
<input type="text" ng-model="bdayname" required/>
<label>Date:</label>
<input type="date" ng-model="bdaydate" required/>
<br/>
<button class="btn" ng-click="visible = false" type="submit">Save</button>
</form>