无法从Angular 6中的UiDatepicker获取所选日期

问题描述 投票:0回答:1

我正在为Angular 6使用UIDatepicker。

 <section class="col col-6">
<label class="w-100"> <i class="icon-append fa fa-calendar calendar-ico"></i>
<input type="text" class="input2 w-50" name="Transdate"
formControlName="startdate" id="startdate"
[saUiDatepicker]="{minRestrict:'#finishdate'}" placeholder="start date" />
</label>
</section>

我试图从表单控件获取日期如下:

this.form.get('Transdate').value

它返回空值而不是选定日期。

angular uidatepicker
1个回答
0
投票

您的表单控件是startdate

this.form.get('startdate').value

您正在尝试访问表单控件中不存在的控件Transdate。如果你的控件名是逻辑.ts中的Transdate,那么在HTML中将formControlName更改为formControlName="Transdate"

© www.soinside.com 2019 - 2024. All rights reserved.