I created a Hijri calendar and I need to take the input from the user and send it to the backend, my HTML code :
<div class="form-row ">
<div class="form-group col-md-6 mb-4">
<label class="w-100 d-block"> From </label>
<mat-form-field class="w-100" matStartDate>
<input matInput [min]="currentDate" name="dp" (ngModelChange)="select(model)" formControlName="DueDate" />
<ngb-datepicker class="rtl" [firstDayOfWeek]="7">
</ngb-datepicker>
</mat-form-field>
</div>
<div class="form-group col-md-6 mb-4">
<label class="w-100 d-block">To</label>
<mat-form-field class="w-100" matEndDate>
<input matInput readonly=true [min]="minDate" name="dp" (ngModelChange)="select(model)" formControlName="ExpiryDate" [(ngModel)]="lastDate" />
<ngb-datepicker class="rtl" #dp [firstDayOfWeek]="7">
</ngb-datepicker>
</mat-form-field>
</div>
</div>
You need make a function to transform the NgbDateStructure to the type of data you use in your dbs
Generally you send to a dbs a string in ISO format yyyy-MM-dd
Or is use a Date object
But I see a few confussed your code. I imagine you get the data using a service. I like when get the data from a http.client, transform de props type Date in Date object -generally you received the types date as string, so, in service use map to transform the data
Idem if you has a function to get a list of objects
But ngb-datepicker use NgbDateStructur, so you need transform when received the data and when send the data. Generally you has in component a function createForm
Now you has a form. see that ONLY use
formControlName
in your component.ts
In submit we can use the functions related at first