I want to restrict the future and past days using Angular 4 Date-Picker.I just want to enable Current Date[today] only.How can i solve this.
Can anyone have idea...???
This is my template:
<input type="text" placeholder="FromDate" class="form-control"
placement="top"
formControlName="fromDate"
[bsConfig]="{ dateInputFormat: 'DD-MM-YYYY' }"
bsDatepicker style="padding: 16px">
bsDatepicker has a property [minDate]
and [maxDate]
, so you set those to "today" and inside your components constructor you do:
component.ts
today=new Date();
component.html
<input ... bsDatepicker ... [minDate]="today" [maxDate]="today" ... >
Anyway, having a datepicker when you don't really allow the user to select a date other than today makes no sense, you might as well default it to "today".