I have a input type date at angular 4 and I have 2 field of Date picker, when I pick for example from 23.03.2018 to 29.03.2018 when I press save the date is taking the today date this is not changing, how it is possible this to happen. I tried with ngModelChange to change the value but in the database it is sending like the today date... Below you can find a code.
<app-input-field orientation="top" label="Beginning Date">
<input [min]="today" type="date" step="1" [(ngModel)]="newCreate" style="width:250px">
</app-input-field>
<br>
<app-input-field orientation="top" label="Ending Date">
<input [min]="today" type="date" step="1"
[(ngModel)]="newEnd" style="width: 250px;">
</app-input-field>
Here is the TS file
newCreate: string = new Date().toISOString().substring(0, 19);
newEnd: string = new Date().toISOString().substring(0, 19);
Here is when I click to save.
save() {
// How to convert here because when is saved it is saved like date
//with minutes and everything else.
this.newProject.name = this.newProjectName;
this.newProject.state = this.newState;
this.newProject.type = this.newType;
this.newProject.created = new Date(this.newCreate);
this.newProject.ending = new Date(this.newEnd);
this.newProject.category = this.category;
this.newProject.subProjectIds = this.subProjectIds;
this.store.dispatch(new UpsertProjectAction(this.newProject));
this.dialogRef.close(this.newProject);