(ngModelChange)无法与[ngModel]一起正常使用

时间:2019-10-07 12:50:22

标签: angular7

我正在将以下代码用于HTML:

<input #dp="bsDatepicker" bsDatepicker [bsConfig]="{ dateInputFormat: 'DD- 
  MMM-YYYY' }" [(ngModel)]="myDate" (ngModelChange)="updateMyDate($event)" 
  name="myDate" type="text">

myDate: any;
updateMyDate(event) {
   today = '07-Oct-2019'
   if(new Date(event) > new Date(today)) {
      this.myDate = today;
   } else {
      this.myDate = event;
   }
}

如何使用(ngModelChange)在HTML上更新myDate的值?

0 个答案:

没有答案