ngx-daterangepicker-material icon indicating copy to clipboard operation
ngx-daterangepicker-material copied to clipboard

Cannot set empty input by default

Open com-xuonghuynh opened this issue 4 years ago • 5 comments

Versions

  • Angular version: 8
  • component version: 2.1.9

Describe the bug I want to set the input with empty and placeholder, but it always display to current date. I tried to set ngModel with startDate and endDate with null value but not success.

<input class="form-control date-select" type="text"
	id="filter-date"
	ngxDaterangepickerMd
	[(ngModel)]="filter_date"
	[showCustomRangeLabel]="true"
	[alwaysShowCalendars]="true"
	[ranges]="ranges"
	[linkedCalendars]="true"
        opens = "right"
	[isInvalidDate] = "isInvalidDate"
	[locale]="{format: 'DD MMM YYYY', firstDay: 1}"
	[showClearButton]="true"
	(datesUpdated)="filterDate()"
	placeholder="Select date...">  
this.filter_date = {
            "startDate": null,
            "endDate": null
        }

com-xuonghuynh avatar Jul 15 '20 04:07 com-xuonghuynh

Please provide solution for this asap. Instead for ngModel I am using fromControl but having same issue.

After reset daterange picker value when we remove(display: none) and show element again it comes with default value set with current date image

Not sure why it is happening. although the formControl value show start and end date null only. Not Understand this magic.

madhuri-bhamre-003 avatar Jul 20 '20 17:07 madhuri-bhamre-003

Hey @com-xuonghuynh , you have found solution but if not then please refer to the following solution, hope this helps -

  1. Instead of ngModel use formControlName and pass your object as string type
  2. Remove placeholder.
  3. Remove isInvalidDate if not required else return a null value for your use case

Hope it woks!!

RupinSahu avatar Aug 27 '20 05:08 RupinSahu

Please provide solution for this asap. Instead for ngModel I am using fromControl but having same issue.

After reset daterange picker value when we remove(display: none) and show element again it comes with default value set with current date image

Not sure why it is happening. although the formControl value show start and end date null only. Not Understand this magic.

Hope you found the solution for it but if not then try providing an any or string type value to formcontrol where if it is any type then it should not contain even start & end date attributes.

My code snippet for your reference, where zval is a string type value - <input type="text" ngxDaterangepickerMd formControlName="zval" [showCustomRangeLabel]="true" [alwaysShowCalendars]="true" [ranges]="propertyMetaData.periods" [linkedCalendars]="false" [locale]="{direction: 'ltr'}" [lockStartDate]="false" [showDropdowns]="true" [timePicker]="propertyMetaData.showTime" [showClearButton]="propertyMetaData.clear" drops="down"/> Hope this helps. Let me know if it works for you, copied to @com-xuonghuynh

RupinSahu avatar Aug 27 '20 05:08 RupinSahu

Hello I am facing issue while setting default value when i am adding 7 days as default it is taking as custom range option only but when i disable timePicker it takes as 7 days but its fails Screenshot 2020-11-05 at 8 02 57 PM . Please provide a solution Thanks

anupam42 avatar Nov 05 '20 14:11 anupam42

I found solution, u can set ngModel to undefined, its display your placeholder instead of today date :

Capture d’écran 2020-11-15 à 11 48 29 Capture d’écran 2020-11-15 à 11 49 08

In my front : Capture d’écran 2020-11-15 à 11 49 31

mbenfriha avatar Nov 15 '20 10:11 mbenfriha