1

When I started to use the datepicker, the html changed to:

<div class="form-group col-md-4">
<label for="arrivalDate">Entry and Departure</label>
<input formControlName="arrivalDate" class="form-control" id="arrivalDate" placeholder="mm/dd/yyyy - mm/dd/yyyy" bsDaterangepicker [minDate]="minDate" [bsConfig]="dpConfig">

That have a component the next:

this._form = this.fb.group({
   // Search basic
   destination: ['', Validators.required],
   arrivalDate: [null, Validators.required],
   qtyAdults: [0, [Validators.required, Validators.min(1) ]],
   qtyChilds: [0, Validators.required ],
   childsage: this.fb.array([]),
   adultsage: this.fb.array([]),
   serviceType: [],
   qtyProduct: ['1', Validators.min(1)]
});

So, while it was the input type date the Validators did not fail, but when changing it to the datepicker of ngx-bootstrap, it gives error.

The error in the next:

Error: There is no FormControl instance attached to form control element with name: 'arrivalDate'

Before when I was using does not gives error, but with this datepicker, started to give that error

I'm using this https://valor-software.com/ngx-bootstrap/#/datepicker

3
  • I don't really understand the difference of your code before and after the error. You "started to use the datepicker" (which one?) and then "when changing it to the datepicker of ngx-bootstrap, it gives error" so how was your code before? Commented Dec 7, 2017 at 8:55
  • I already solved. It was a mistake with the creation of the formData that was staying active, so with an if it was solved! Thanks for answering! Commented Dec 7, 2017 at 14:24
  • then you can answer your own question with your solution, in case someone else has the same problem Commented Dec 7, 2017 at 15:44

1 Answer 1

2

In the html I added a div with:

*ngIf = "isFormHotelActivate"

and in the component:

_initFormHotels() {
    this._formT = this.fb.group({
       // Search basic
       origin: [''],
       destination: ['', Validators.required],
       arrivalDate: [null, Validators.required],
       qtyProduct: [1, Validators.min(1)]
    });
this.isFormHotelActivate = true;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.