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

inline usage throws an error ERROR TypeError: dir.valueAccessor.writeValue is not a function #527

Open
VolodymyrL87 opened this issue Jun 30, 2023 · 1 comment

Comments

@VolodymyrL87
Copy link

Versions

  • Angular version: 15.2.4
  • component version: 6.0.4

Describe the bug
When inline component is used with [(ngModel)] or formControl, there is error in console: ERROR TypeError: dir.valueAccessor.writeValue is not a function
at setUpControl (forms.mjs:2939:23)
at FormControlDirective.ngOnChanges (forms.mjs:4551:13)
at FormControlDirective.rememberChangeHistoryAndInvokeOnChangesHook (core.mjs:1521:14)
at callHook (core.mjs:2444:18)
at callHooks (core.mjs:2403:17)
at executeInitAndCheckHooks (core.mjs:2354:9)
at refreshView (core.mjs:10341:21)
at refreshComponent (core.mjs:11385:13)
at refreshChildComponents (core.mjs:10116:9)
at refreshView (core.mjs:10376:13)

To Reproduce
Steps to reproduce the behavior:

  1. Create a component with <ngx-daterangepicker-material [formControl]="control"></ngx-daterangepicker-material> or <ngx-daterangepicker-material [(ngModel)]="range"></ngx-daterangepicker-material> where control is```
    new FormControl(
    {
    endDate: new Date(),
    startDate: new Date(),
    }
    )
2. OPen browser console
**Expected behavior**
there is no errors in console

**Screenshots**
![image](https://github.com/fetrarij/ngx-daterangepicker-material/assets/133101541/88766c89-82db-4395-bc53-c6656cca7fbe)

**Stackblitz link**
If applicable, add stackblitz link.

**Additional context**
Add any other context about the problem here.
@YogeshK05
Copy link

Hello @VolodymyrL87,

I also encountered the same issue. I think the problem is you can't use formControl or ngModel with the inline component. What you can do instead is you can listen to the event choosedDate which is emitted when you select a date.

<ngx-daterangepicker-material (choosedDate)="choosedDate($event)"> </ngx-daterangepicker-material>

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