Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for reactive forms #4

Open
iamnimnul opened this issue Dec 4, 2017 · 2 comments
Open

Support for reactive forms #4

iamnimnul opened this issue Dec 4, 2017 · 2 comments

Comments

@iamnimnul
Copy link

iamnimnul commented Dec 4, 2017

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
Copy link
Owner

would this be instead or addtion to ngmodel?

@iamnimnul
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants