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>