Topic: date-picker ngModel not work and solution I found

Chen Xiao pro asked 5 years ago


I want use [(ngModel)] to two way binding data, but it is not work. I check the date picker's ts file, found the solution: 1. use selDate to set init date : [selDate]="publishDate" now = new Date(); publishDate = {year: this.now.getFullYear(), month: this.now.getMonth() + 1, day: this.now.getDate()}; 2. set date when date change (dateChanged)="onDateChange($event)" onDateChange(event) { console.log(event); } Then you'll get formatted date string like "2017-10-20", if you set format is "yyyy-mm-dd"

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags