Topic: Unable to bind Date object to mdb datepicker
Subrata Paul pro asked 6 years ago
Damian Gemza staff answered 6 years ago
Subrata Paul pro answered 6 years ago
In component.ts : export class HolidayComponent implements OnInit { public myDatePickerOptions: IMyOptions = { closeAfterSelect:true, minYear:1975, maxYear:2075, dateFormat: 'dd/mm/yyyy' }; holiday: Holiday= new Holiday(); constructor(private HService: HolidayService) { } ngOnInit() { this.showHolidayLoader = true; this.HService.GetHolidays().subscribe(res => { this.showHolidayLoader = false; this.holiday = res; },err => { this.showHolidayLoader = false; }) } } In Html : <mdb-date-picker name="TODT" [options]="myDatePickerOptions" [placeholder]="'Holiday End'" [(ngModel)]="holiday.TODT" required ></mdb-date-picker> Holiday Interface : export class Holiday { TODT: Date; HOLIDAY: string; }Regards, Subrata Paul
Damian Gemza staff answered 6 years ago
public myDatePickerOptions:IMyOptions= { closeAfterSelect:true, minYear:1975, maxYear:2075, dateFormat:'yyyy-mm-dd', startDate:'2018-11-11' }; ngOnInit() { constd=newDate(); this.myDatePickerOptions.startDate=`${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`; }
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: 6.2.3
- Device: Windows
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No