'Angular ngbDatePicker returning Form as invalid when the date is null or empty

Form returning as invalid when the date is null or empty.

this.mBasicsForm = this.fb.group({
        openDateFor: [null,[],''],
        closeDateFor: [null,[],''],
})

The above works only on the initialization. Each time i click on a button then the Form is returned as invalid, giving error as it is required.

Can someone please suggest how do we handle the case where i click on the button and i want my form to be valid when Date is null or empty.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source