如何在 ngx-bootstrap datepicker 中设置自定义日期
How to set custom date in ngx-bootstrap datepicker
我正在使用 ngx-bootstrap datepicker
。我希望在加载 date-picker
时突出显示自定义日期。我在某个变量中存储了一个日期,并希望选择该日期(突出显示)。
component.ts
private dob : string = '2017/07/07';
component.html
<datepicker [activeDate]="dob" [showWeeks]="false" [startingDay]="1" [formControl]="form.controls[dob]"></datepicker>
但这不起作用。默认情况下,即使在设置 activeDate
之后,也会选择今天的日期。如何做到这一点?或者我可以使用任何其他属性来代替 activeDate
吗?日期有什么特殊格式吗?
ngModel
帮了我大忙。我们可以将其设置为 ngModel
,而不是将值设置为 activeDate
。 activeDate
也接受 Date 对象,如果值为字符串,则需要进行转换。
我也必须删除 formControl
,因为它不能与 ngModel
一起使用。
<datepicker [(ngModel)]="dob" [showWeeks]="false" [startingDay]="1" (selectionDone)="showDatePicker = false"; ></datepicker>
我正在使用 ngx-bootstrap datepicker
。我希望在加载 date-picker
时突出显示自定义日期。我在某个变量中存储了一个日期,并希望选择该日期(突出显示)。
component.ts
private dob : string = '2017/07/07';
component.html
<datepicker [activeDate]="dob" [showWeeks]="false" [startingDay]="1" [formControl]="form.controls[dob]"></datepicker>
但这不起作用。默认情况下,即使在设置 activeDate
之后,也会选择今天的日期。如何做到这一点?或者我可以使用任何其他属性来代替 activeDate
吗?日期有什么特殊格式吗?
ngModel
帮了我大忙。我们可以将其设置为 ngModel
,而不是将值设置为 activeDate
。 activeDate
也接受 Date 对象,如果值为字符串,则需要进行转换。
我也必须删除 formControl
,因为它不能与 ngModel
一起使用。
<datepicker [(ngModel)]="dob" [showWeeks]="false" [startingDay]="1" (selectionDone)="showDatePicker = false"; ></datepicker>