I have a problem with binding value with DateTimePicker jQuery from xdsoft : https://xdsoft.net/jqplugins/datetimepicker/
I built FormControl using ReactiveFormsModule
I have <form [formGroup]="myForm">
And there are two inputs in it:
<input type="text" formControlName="name">
<input type="text" id="datetimepicker" formControlName="date" />
FormControl for "name" works fine.
However, FormControl for "date" doesn't show any values in:
{{ myform.value | json }}
StackBlitz:
https://stackblitz.com/edit/angular-mmsjj7?file=src/app/app.component.ts
Try this -
$('#datetimepicker').datetimepicker({
timepicker: false,
format: 'd.m.Y',
onClose: (dateText, inst) => {
this.myForm.controls['date'].setValue(dateText);
}
});
Just remove form control from the date as we are assigning explicitly value to his control.
<input type="text" formControlName="name">
<input type="text" id="datetimepicker" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.