【发布时间】:2013-03-05 12:40:08
【问题描述】:
我有一个表单,我在输入中使用了required tag - 这工作正常,但在我的提交按钮上我有ng-click="visible = false",它在提交数据时隐藏表单。
如果所有验证都正确,我怎样才能让它只设置为 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>
【问题讨论】:
标签: html forms validation angularjs