2

I am not able to bind the input date range using ngModel or form-control. It gives an error- ERROR TypeError: dir.valueAccessor.writeValue is not a function. choosedDate method is invoked upon chosing or clicking on a date.

<ngx-daterangepicker-material 
        [ranges]="ranges"
        [showCustomRangeLabel]="true"
        [maxDate]="maxDate" 
        (choosedDate)="choosedDate($event)"
        [autoApply]="true"
        [(ngModel)]="selected">
    </ngx-daterangepicker-material>
Armen Stepanyan
  • 1,618
  • 13
  • 29
SanDash
  • 733
  • 1
  • 6
  • 15
  • I have a very good experience with bootstrap daterange controls. very efficient and simply configuration. please follow this url if you are interested. do let me know if you need any help. Thanks https://valor-software.com/ngx-bootstrap/#/datepicker – Lajwat Kumar Feb 25 '20 at 07:45
  • Yes, I have partially gone through the docs but unable to figure it out. It is working fine with input type directive but showing error with inline form of the datepicker. – SanDash Feb 25 '20 at 07:46
  • @LajwatKumar Looks good. But is there functionality for default labelled date ranges like yesterday, last week, last month, year etc.? Can u suggest any library with such feature? – SanDash Feb 25 '20 at 07:50
  • If you've read the docs you should've seen that in the examples that ngModel can be used when you use ngx-daterangepicker-material as a directive. For the inline usage you have to use choosedDate event what will emit the selected value. This means that you should use that "selected" variable in the choosedDate() method... – standby954 Feb 25 '20 at 07:55
  • @standby954 yes I got that part. sorry if I didn't elaborate my requirement exactly, actually I am using a calendar icon to open and close the inline datepicker. If the user selects a date range eg Last month, then it should stay highlighted on closing and opening the datepicker again. For which I thought I need to bind the input. – SanDash Feb 25 '20 at 08:02

0 Answers0