Closed Joelius300 closed 4 years ago
I have the same issue
I have the same issue too. any solution yet?
Hey @Joelius300 , I guess you can force the calendar to update the selection by, getting the instance of the datePicker with @ViewChild and updating your chosenDate
function as follows
@ViewChild(DaterangepickerComponent, { static: false }) datePicker: DaterangepickerComponent;
chosenDate(chosenDate: { chosenLabel: string; startDate: moment.Moment; endDate: moment.Moment }): void {
console.log(chosenDate);
this.inlineDate = chosenDate;
/*add this*/
this.datePicker.updateView()
}
Thanks for the anwswer, but i've chenged to this module ng-bootstrap and is working perfectly.
@kirega Thank you for the suggestion but unfortunately that doesn't solve the issue. It doesn't show the selection even when calling updateView
. It's also suboptimal conceptually because the selection should be highlighted and updated before I submit.
Is there any workaround for this or a foreseeable fix? It seems like I'm not the only one having this issue.
I have the same issue
same here
I am facing the same issue. Any Update ?
I've fixed(workaround) by adding simple mixin to my app styles. https://github.com/fetrarij/ngx-daterangepicker-material/issues/266
I've fixed(workaround) by adding simple mixin to my app styles. #266
Thanks, It's Working Fine
Seems to work, thank you. It still seems to have an issue because the start-date's corners aren't rounded (with pink-bluegray) but for now that's good enough :)
@Joelius300 I'm sorry this is not a bug, with inline picker we dont use ngModel, just use startDate
and endDate
[startDate]="selected?.startDate"
[endDate]="selected?.endDate"
take a look at Basic In-line Timepicker Example in https://fetrarij.github.io/ngx-daterangepicker-material/simple @djoyrocks @akrolasik @nimax1998 @kirega @1h3b3s1 you should do the same
Hi @fetrarij,
Except if I'm wrong the props that you're mentioning are not present in the inline picker example, this is confusing and probably why the issue has be opened. Updating the example will help.
Thanks :)
@nboukeffa check the link I provided, it's there
@fetrarij Are you sure? The issue also reproduces without using ngModel like so:
(also why did you even think I used ngModel? I didn't use it in my repro)
picker.component.html
<ngx-daterangepicker-material (chosenDate)="chosenDate($event)"></ngx-daterangepicker-material>
<div>Chosen date: {{ inlineDate | json }}</div>
picker.component.ts
import { Component, ViewChild } from '@angular/core';
import * as moment from 'moment';
@Component({
selector: 'app-picker',
templateUrl: './picker.component.html',
styleUrls: ['./picker.component.css']
})
export class PickerComponent {
inlineDate: { chosenLabel: string; startDate: moment.Moment; endDate: moment.Moment };
chosenDate(chosenDate: { chosenLabel: string; startDate: moment.Moment; endDate: moment.Moment }): void {
this.inlineDate = chosenDate;
}
}
Also it's not related to inline at all. You can also reproduce it like this:
<mat-form-field>
<input
type="text" <-- this line isn't documented but without it it doesn't work correctly (no styling and date isn't displayed)
matInput
ngxDaterangepickerMd
showCancel="true"
placeholder="Choose date"
[(ngModel)]="selected"
[showDropdowns]="true"
[lockStartDate]="false"
[customRangeDirection]="false"
(ngModelChange)="ngModelChange($event)"
(change)="change($event)"
/>
</mat-form-field>
import { Component } from '@angular/core';
import * as moment from 'moment';
@Component({
selector: 'app-picker',
templateUrl: './picker.component.html',
styleUrls: ['./picker.component.css']
})
export class PickerComponent {
selected = {
startDate: moment('2015-11-18T00:00Z'),
endDate: moment('2015-11-26T00:00Z'),
};
ngModelChange(e): void {
console.log(e);
}
change(e): void {
console.log(e);
}
}
The code is taken from the link you posted (your demo page).
I'm almost certain this has to be a styling bug in regard to the pre-built styles because the here mentioned workaround fixes the issue. However, it's not documented anywhere and I believe a lot of people (especially beginners who have trouble helping themselfs with angular) use angular material with pre-built themes.
Could you please investigate this again?
Ps. Cannot reopen because I didn't close it myself.
v3.0.2 is up. From there, if you install the plugin with ng add ngx-daterangepicker-material
you will be prompted with a theme selector, then the theme you selected will be added in angular.json (styles). If you added the plugin manually just includes your preferred theme in node_modules/ngx-daterangepicker-material/prebuilt-themes/
Just a note because someone else might trip on this: You need both styles in the styles
array, otherwise it's completely messed up.
When installing I got
"styles": [
"./node_modules/ngx-daterangepicker-material/prebuilt-themes/pink-bluegrey.css",
"src/styles.scss"
],
but you need
"styles": [
"./node_modules/ngx-daterangepicker-material/prebuilt-themes/pink-bluegrey.css",
"./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css",
"src/styles.scss"
],
Versions
Describe the bug When adding a simple in-line daterangepicker to a project which already has material installed and setup, the selection isn't highlighted. Also the style is off but that seems to be a side-effect of that (maybe #282 is related?).
I'm new to angular and I don't know what I'm missing here. Is there a step that's not documented in the readme (like adding moment.js) or is this a bug?
To Reproduce Basically follow the readme:
ng new repro-project --skipGit=true --interactive=false
cd repro-project
ng add @angular/material
npm i -D ngx-daterangepicker-material
npm i moment
(not in readme?)ng generate @angular/material:navigation nav
ng g component picker
Copy basic in-line example from demo picker.component.html
picker.component.ts
<app-nav></app-nav>
<!-- Add Content Here -->
in nav.component.html with<app-picker></app-picker>
ng serve
Expected behavior The date is selected and displayed in the div below the picker.
The selection is highlighted like in the basic in-line demo.
Actual behavior The date is selected and displayed in the div below the picker but nothing is highlighted.
Screenshots Expected (taken from demo):
Actual (10. - 12. June should be highlighted but it's not):
Stackblitz link I tried to create a stackblitz with the same steps but there are errors I don't know how to fix :/
https://stackblitz.com/edit/angular-ivy-z1rwff
Additional context Here's a full project which was created by following the repro steps that shows the issue: repro-project.zip
Things I tried:
@import '../node_modules/ngx-daterangepicker-material/daterangepicker-theme.scss';
to the top ofstyles.css
but doesn't make a difference.styles
array in angular.json and instead importing it in styles.css with@import '../node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css';
. No difference either.>=9.0.0 with @angular/material
so the version^3.0.1
(which npm added automatically) should be fine.