question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ngModel does not work with Angular 4 reactive forms

See original GitHub issue

Your latest update (4.3.0) uses ngModel to bind data, How do you bind data to your date-time-picker when implementing data entry forms using Angular 4’s reactive forms? Reactive forms do not use ngModel.

I tried using [ngModel]="momentValue" (onChange)="setMoment($event)" as referenced in your help, however, the Date/Time value in popup was never getting bound to the value in the form. The popup would just default to today’s value.

Is it possible to use date-time-picker with reactive forms approach for Angular 4?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vorlifcommented, Jul 20, 2017

Hey Tomschreck,

the last version implements the ControlValueAccessor interface. That means you can use the date-time-picker like any other form component (input, select, etc.). You can now easy use [formControl]="momentValue" instead of [ngModel]="momentValue".

I hope this helps.

1reaction
DanielYKPancommented, Aug 12, 2017

@Vorlif @itsmekhanh Try the package version @4.3.2

See if this fixed the issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Two way binding in reactive forms - Stack Overflow
ngModel or Template driven forms and reactive forms( model driven forms ) can be mixed together. for example, it's ...
Read more >
How to bind reactive form input data with ngModel in Angular ...
Friends in this post, I am binding my reactive form input data with ngModel. I have also used bootstrap because to make reactive...
Read more >
Angular Forms Guide: Template Driven and Reactive Forms
This post is an in-depth comparison between the two different alternatives for building forms in Angular - Template Driven Forms and ...
Read more >
FormControlName - Angular
Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and is scheduled...
Read more >
Angular Form Controls and ngModels Don't mix
Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found