I'm trying to use bootstrap's ngbDatepicker in an Angular application to support a non-required date field, but if the field comes in with a date, setting the date to null will result in the field/form being marked as invalid.
Using the code below, if note.expires_on
initially has a date and is then set to null, the form is marked invalid:
<input name="expires_on" [(ngModel)]="note.expires_on" ngbDatepicker #datePicker="ngbDatepicker">
I see from the post below that if the date is initialized as null, then a null value will not result in an invalid form, but in my case, initializing as null doesn't seem like an option.
How to mark ngbDatepicker Valid in form even when no value is selected