atais / ng2-eonasdan-datetimepicker

A wrapper directive around the Eonasdan Datepicker v4 component.
MIT License
34 stars 23 forks source link

Form/NgModel Support #25

Closed lommez closed 6 years ago

lommez commented 6 years ago

When using something like this:

<form #form="ngForm" novalidate>
  <input a2e-datetimepicker [date]="startDate" [(ngMode)]="startDate" name="startDate" [options]="a2eOptions" (onChange)="dateStartChange($event)" required/>
</form>

The ngModel will conflict with the date property and shows non formatted date.

Anyone have an example of how to make it work with a form and ngmodel directive in angular?

anuraagbitcot commented 6 years ago

I listen to (onChange) emitter and assign the value of it to my ngModel in component.ts file. This way I can display date in a particular format and send back to my server in the format needed.

Note: onnChange's $event gives moment object.

atais commented 6 years ago

So now as of 0.1.0 is this ticket still valid? @fetrarij

fetrarij commented 6 years ago

The 0.1.0 is for form/ngModel . You can now use ngModel and ngModelChangeinstead of date and onChange