2

This works :

DetailEvent is a object which has start_time of type Date

 <span class="month">{{DetailEvent.start_time   | date: 'MMM'}}</span>

This does not work:

 <div class="col-md-6"><input type="text" [(ngModel)]='DetailEvent.start_time| date: 'MMM''> <span class="calender-to">to</span> </div>
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396

1 Answers1

1

Pipes generally don't work with `two-way-binding

[(ngModel)]='fromDate | date: 'MMM''

should be

[ngModel]="fromDate | date: 'MMM'" (ngModelChange)="fromDate = $event"
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • The 1st code line (your code with `[(ngModel)]`) is just a short form of the 2nd line (my code). The short form doesn't work if the expression is not a simple reference because how would `ngModel` be able to assign a value to `fromDate | date: 'MMM'`? – Günter Zöchbauer Feb 13 '17 at 08:52