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

formControlName doesn't work. #41

Closed
adrianoviana opened this issue May 17, 2018 · 2 comments
Closed

formControlName doesn't work. #41

adrianoviana opened this issue May 17, 2018 · 2 comments

Comments

@adrianoviana
Copy link

here s my code:

dateOptions: FlatpickrOptions = {
defaultDate: new Date(),
locale: Pt.pt,
dateFormat:'d/m/Y'
};

myForm = formBuilder.group({
...
dtaInicio : [''],
dtaFim : [''],
});
<ng2-flatpickr formControlName="dtaInicio" [config]="dateOptions" >

myForm.value.dtaInicio and myForm.value.dtaFim comes always empty!

@mezoistvan
Copy link
Owner

closed due to inactivity

@ghiscoding
Copy link

I'm having this problem too, basically the issue is that setting the defaultDate with the FlatpickrOptions shows the value in the input but does not update the value in the Reactive Form Control itself. So on top of using the defaultDate, I also have to set it with the Reactive Form controls.

So if we take the example from original question

dateOptions: FlatpickrOptions = {
defaultDate: new Date(),
locale: Pt.pt,
dateFormat:'d/m/Y'
};

// doing this extra command does work
myForm = formBuilder.group({
  dtaInicio : [new Date()],  // <<-- SET IT HERE TOO
});

That works but it's a little confusing not knowing that the defaultDate doesn't work from the get go.

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

3 participants