xtianus79 / multiple-date-picker-angular

Multiple Date Picker for Angular: This includes Angular 2+ / 4+ / 5+ to utilize a lightweight and clean calendar allowing user to select multiple dates, single, use custom callback on (de)selection. You can also specify off days or already selected days. You can also select a range of dates with start and end inputs... This will also calculate all the days inbetween.
http://xtianus79.github.io/MultipleDatePicker
MIT License
14 stars 19 forks source link

Support for reactive forms #4

Open iamnimnul opened 6 years ago

iamnimnul commented 6 years ago

Hi, is there any view to support reactive forms i.e. formGroupName directive?

Example error when I want to use it with ngModel inside reactive form in angular 4 (v4.4.6):

<form [formGroup]="deliveryFormGroup">
  <multiple-date-picker
      [disallowBackPastMonths]="true"
      [disableDaysBefore]="true"
      [(ngModel)]="dates">
  </multiple-date-picker>
</form>

cause error:

ERROR Error: 
      ngModel cannot be used to register form controls with a parent formGroup directive.  Try using
      formGroup's partner directive "formControlName" instead.  Example:

    <div [formGroup]="myGroup">
      <input formControlName="firstName">
    </div>

    In your class:

    this.myGroup = new FormGroup({
       firstName: new FormControl()
    });

      Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:

      Example:

    <div [formGroup]="myGroup">
       <input formControlName="firstName">
       <input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
    </div>
xtianus79 commented 6 years ago

would this be instead or addtion to ngmodel?

iamnimnul commented 6 years ago

In produced error with example (very bottom piece of code) you can see that formControlName and ngModel are used at same time.