我在Angular应用程序中使用bootstrap datepicker。我想添加一个验证以验证日期是否正确(而不是“无效日期”),但是当我为此控件添加formControlName="birthDate"
时,日历无法正常工作,则在小弹出窗口,请您告诉我如何解决此问题?
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" class="form-control input-sm" id="birthDate" name="birthDate"
formControlName="birthDate"
bsDatepicker
[bsConfig]="{dateInputFormat: 'DD/MM/YYYY'}"
[(ngModel)]="response.date"
[disabled]="IsNotModifiable()">
</div>
我尝试添加一个属性(input)=verify()
来检查日期,但从未触发过。
答案 0 :(得分:0)
<div class="input-group mb-3">
<input [(ngModel)]="Date" placeholder="MM/DD/YYYY" class="form-control" formControlName="Date" #dateneeded ="bsDatepicker" bsDatepicker [bsConfig]="datepickerConfig">
<div class="input-group-append">
<span class="input-group-text" (click)="dateneeded.show()">
<i class="far fa-calendar-plus" value="open"></i>
</span>
</div>
</div>
这段代码对我有用。确保已将bsdatepicker模块导入了appmodule.ts