I am using angular powered bootstrap ngbDatepicker. I have created my own custom control which will be used in different pages for date capturing as follows.
<form-date
[label]="'Date of birth'"
[name]="'inputCPDDOB'"
[(ngModel)]="birthDate"
placeholder="mm/dd/yyyy"
required
>
</form-date>
Here I have passed birthDate
as my model object.
I want
- User should be able to choose the date by clicking the CAL button (beside the text box),
- User should be able to type a date in format 'MM/DD/YYYY' in the textbox.
- After selecting or typing the date, the model should be updated as string with format 'YYYY-MM-DD' by two way data binding.
I have successfully did point#1 and point#2 the date format of text box as MM/DD/YYYY by inheriting NgbDateParserFormatter
But I am not able to change the model structure. While I need to communicate with my web service as 'YYYY-MM-DD' format.
Please help me to achieve the same. Here is the plunker attached.