Topic: Angular DatePicker not showing correct date at top
Mark Olive pro asked 7 years ago
<mdb-date-picker name="mydate" [options]="myDatePickerOptions" [placeholder]="'Enter Start Date'" [formControl]="startDate" required ngDefaultControl> </mdb-date-picker> this.startDate = '21-02-2018'; // UK Date formatSee: https://photos.google.com/share/AF1QipNX1ldvqsnNmQxs8pZ6wKXu2NyerdwPQhY-H-mzXdkTPjpwyFHygPIICHVMZtwuAg?key=ZTV6MmhKTlJaQXp0a3l3SVhxUWcyekdhejBvRU13 This is very confusing. Is there anyway to get both the top 'title' and the calendar part of the datepicker to show the initial date set?
Damian Gemza staff answered 7 years ago
<mdb-date-picker #datePickername="mydate" [options]="myDatePickerOptions" [placeholder]="'Selected date'" [(ngModel)]="model"required></mdb-date-picker>
import { Component, OnInit, ViewChild, AfterViewInit} from '@angular/core'; import { MDBDatePickerComponent } from './../../../typescripts/pro/date-picker/datepicker.component';3. Add viewChild to your's component.ts file:
@ViewChild("datePicker") datePicker: MDBDatePickerComponent;4. And final step is to set your's default date in ngAfterViewInit():
ngAfterViewInit(){ setTimeout(() =>this.datePicker.onUserDateInput("2017-10-13"), 0); }This should works fine to you. If not, let me know. Best Regards, Damian
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: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No