我有三个单选按钮:Active,Dissolved,Concluded。 如果选择了Active,则“Active”将存储在表中的列中。 如果选择了Dissolved,则会显示带有日期选择器的输入。这对于Dissolved来说是一样的。因此,该列设置为nvarchar。 我发现的是当我保存屏幕时没有任何反应。我逐步完成了代码并进入了这一行:
<div class="col-xs-7 form-inner-group padRt0">
<div class="clearfix stackDate">
<input name="DissolutionConcludedStatusDate" id="DissDate1_0" type="radio" ng-model="vm.regulatoryApproval.DissolutionConcludedStatusID" ng-value="1"> Active<br />
</div>
<div class="clearfix stackDate">
<input name="DissolutionConcludedStatusDate" id="DissDate1_1" type="radio" ng-model="vm.regulatoryApproval.DissolutionConcludedStatusID" ng-change=vm.setDate() ng-value="2">
Dissolved <span ng-if="vm.regulatoryApproval.DissolutionConcludedStatusID==2">
<input class="form-field cal-field" type="text" ng-required="vm.regulatoryApproval.DissolutionConcludedStatusID==2"
name="DissolvedStatusDate"
ng-model="vm.regulatoryApproval.DissolutionConcludedStatusDate"
datepicker-popup="dd-MMM-yyyy" close-text="Close" ng-model="vm.regulatoryApproval.DissolutionConcludedStatusDate"><br />
<div ng-show="addeditregulatoryapprovalForm.submitted || addeditregulatoryapprovalForm.DissolvedStatusDate.$touched">
<span class="error" ng-show="addeditregulatoryapprovalForm.DissolvedStatusDate.$error.required">Please select a Dissolved date</span>
</div>
</span>
</div>
<div class="clearfix stackDate">
<input name="ConcludedStatusDate" id="DissDate1_2" ng-model="vm.regulatoryApproval.DissolutionConcludedStatusID" type="radio" ng-change=vm.setDate() ng-value="3">
Concluded <span ng-if="vm.regulatoryApproval.DissolutionConcludedStatusID==3">
<input type="date" class="form-field cal-field" ng-required="vm.regulatoryApproval.DissolutionConcludedStatusID==3"
name="ConcludedDate"
ng-model="vm.regulatoryApproval.DissolutionConcludedStatusDate"
datepicker-popup="dd-MMM-yyyy" close-text="Close" ng-model="vm.regulatoryApproval.DissolutionConcludedStatusDate"><br />
<div ng-show="addeditregulatoryapprovalForm.submitted || addeditregulatoryapprovalForm.ConcludedStatusDate.$touched">
<span class="error" ng-show="addeditregulatoryapprovalForm.ConcludedStatusDate.$error.required">Please select a Concluded date</span>
</div>
</span>
</div>
</div>
$ valid评估为false。如果我将鼠标悬停在它上面,我会看到$ error,如果我扩展我看到日期,如果我展开,我看到一个包含一个元素的数组,当我展开时,我看到输入字段中显示的日期。
如果我所看到的是正确的,并且它是造成问题的日期,我只是不知道它为什么会导致问题。在我保存之前,我必须选择一个日期,即使它与已经选择的日期相同。
有什么想法吗?
以下是代码:
{{1}}
答案 0 :(得分:0)
我弄清楚问题是什么。因为我必须在保存表单时将日期保存为数据库中的字符串,所以它被认为是无效的,因为它需要来自datepicker的日期。在将字符串分配给模型之前,我必须将字符串转换为从数据库中提取字符串的日期。