koenz / angular-datepicker

An Angular 2+ datepicker component that animate, can have multiple calendars next to each other, has no dependencies
MIT License
11 stars 1 forks source link

datepicker is not working in mat-menu #6

Open idomiralin opened 5 years ago

idomiralin commented 5 years ago

Hello,

I need to have this datepicker as in airbnb, to have a button, which opens a mat-menu with this datepicker inside of it. I tried to do this:

`

<button mat-raised-button [matMenuTriggerFor]="dateRangeMenu"> {{startEndDate}} <mat-menu #dateRangeMenu="matMenu" [overlapTrigger]="false" class="h-400 w-500">

                <div fxLayout="row">
                    <div fxFlex fxLayoutAlign="start center">
                        <button mat-button>Clear</button>
                    </div>
                    <div fxFlex fxLayoutAlign="end center">
                        <button mat-button (click)="apply()">Apply</button>
                    </div>
                </div>
            </mat-menu>
        </div>`

But I get this error after I choose dates, close the mat-menu and try to open the mat-menu again:

Cannot read property '0' of null at AnimatepickerComponent.getNextMonthArray (ngx-animating-datepicker.js:1081) at AnimatepickerComponent.goToDate (ngx-animating-datepicker.js:988) at AnimatepickerComponent.set selectedDates [as selectedDates] (ngx-animating-datepicker.js:408) at updateProp (core.js:24768) at checkAndUpdateDirectiveInline (core.js:24450) at checkAndUpdateNodeInline (core.js:35151) at checkAndUpdateNode (core.js:35090) at debugCheckAndUpdateNode (core.js:36112) at debugCheckDirectivesFn (core.js:36055) at Object.eval [as updateDirectives]

If I remove [(selectedDates)]="dates", then the error is not appearing anymore, but the problem is that my dates are not saved anymore.

Do you think that this can be achieved? I would be very thankful for a solution.

koenz commented 5 years ago

Hi idomiralin,

What happens with "dates" when the menu is closed? It looks like the dates is invalid.

idomiralin commented 5 years ago

Yes, dates is undefined. No value. Is it possible to replace the input with button? I need this button because I want to achieve an airbnb look for filters.

koenz commented 5 years ago

I will provide a fix for the error: Cannot read property '0' of null.

About the other stuff (replacing input for button?). That is unrelated to the current issue. Please create an new issue and describe more precise what you want to achieve