Coder Social home page Coder Social logo

ng2-daterangepicker's Introduction

Hi there 👋

Nice to meet you. I am looking for interesting projects to contribute to. Contact me for assistance in maintaining PHP, Javascript, Python and Go Open Source Applications. Stuck on a nice innovative business idea? Let's chat. I might be your partner for success.

  • 🔭 I’m currently working on a simple but secret project
  • 🌱 I’m currently learning Product Management
  • 👯 I’m looking to collaborate on Open Source PHP, JavaScript, Python and Go projects
  • 💬 Ask me about the above and planning for a successful product development
  • 📫 How to reach me: check my profile email
  • ⚡ Fun fact: I am a college dropout with 10+ years building software products

ng2-daterangepicker's People

Contributors

dependabot[bot] avatar evansmwendwa avatar fullstackdb avatar jaydiablo avatar joshterrill avatar niklimenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ng2-daterangepicker's Issues

Demo not working on IE11

I’m looking for an Angular 2+ control for date range picker. I tried your control in all browsers but I’m having a problem on IE 11. Here’s a screenshot when I try to run it on IE11:
22

And here’s how it looks like on IE11:
23

Please help. Thanks!

'oncancel' not working

Hi,

I am trying to execute the oncancel.daterangepicker hook from my component. Tried it in the ngAfterViewInit using @ViewChild element.

$(this.el.nativeElement).on('cancel.daterangepicker', function(ev, picker) { console.log('clear called'); });.

I was able to add the 'clear' button, but the hook is not executing. Can you please help on how I can get there?

Thanks.

Loading jQuery from index.html (SystemJS)

Firstly thank you for the great work! It all works great if I install the modules using NPM. But for some reason, I am working in an application which loads the jQuery in index.html and in components, it can be accessible using

declare var jQuery: any;

If I comment out 'jquery': 'npm:jquery/dist/jquery.js' this from systemjs.config.js, I start getting errors in my console on require('jquery') and If I don't and keep both jquerys, the application breaks on quite a lot of places that are using bootstrap and other jquery plugins. Is there a workaround for this issue?

ES6 Build Issue with angular/cli

The uglify-js bundled with webpack breaks when doing a production build with daterangepicker as it does not work with es6.

Is there an es5 version? If not what the best way around it?

The exact build error is:

ERROR in vendor.3171750698bdd8016e8a.bundle.js from UglifyJs
Unexpected token: name (DaterangepickerConfig) [vendor.3171750698bdd8016e8a.bundle.js:67402,6]

Thanks.

Get the date format in another component but does not pik the date format.

@Input() dateFormat : any = "MM-DD-YYYY";
public options: any = {
      locale: { format: this.dateFormat }
 };

In another component is:-
<RangeFilter dateFormat="DD/MM/YYYY"></RangeFilter>

Does not pick up the dateFormat="DD/MM/YYYY". It is pickUp the default set dateFormat.

Please tell us how to solve this problem.

Cannot read property 'remove' of undefined

When I run tests against my component where I'm using the ng2-daterangepicker I get this in the console:

Cannot read property 'remove' of undefined

This is throwed by the ngOnDestroy in the daterangepicker.component.js

Exacly here:
https://github.com/evansmwendwa/ng2-daterangepicker/blob/master/src/app/daterangepicker/daterangepicker.component.ts#L95

I hope somebody can help me out, it is very annoying that i get this log in my tests.

This is how I'm using the datepicker (single-datepicker.component.ts):

import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import * as moment from 'moment'

/**
 * The single date picker component
 *
 * Wrapper around ng2-daterangepicker to achieve similar behavior as the old datepicker
 * [To see all options, methods & Events]{@link http://www.daterangepicker.com/#options}
 *
 * Usage:
 * ```html
 * <app-single-datepicker>
 *    [minDate]="string"
 *    [maxDate]="string"
 *    [defaultDate]="string"
 * </app-single-datepicker>
 * ```
 */
@Component({
	selector: 'app-single-datepicker',
	templateUrl: './single-datepicker.component.html',
})

export class SingleDatepickerComponent implements OnInit {

	/**
	 * Used in moment.js, prefered way to format date
	 * @default empty string
	 * @type {string}
	 */
	static dateFormat = 'YYYY-MM-DD';

	/**
	 * The currently entered value of the input field.
	 */
	enteredValue: string;

	/**
	 * Variable to hold selected and formatted date
	 * @default empty string
	 * @type {string}
	 */
	selectedDate: string;

	/**
	 * The earliest date a user may select
	 * @type {string}
	 */
	@Input()
	minDate: string;

	/**
	 * The latest date a user may select
	 * @type {string}
	 */
	@Input()
	maxDate: string;

	/**
	 * The default date to select when component is loaded
	 * @type {string}
	 */
	@Input()
	defaultDate: string;

	/**
	 * The selected date passed to the parent component
	 */
	@Output()
	outputDate: EventEmitter<string> = new EventEmitter<string>();

	public singlePickerOptions: any;

	/**
	 * Select only single date
	 * @param value
	 */
	private selectSingleDate(value: any): void {
		this.selectedDate = moment(value.start).format(SingleDatepickerComponent.dateFormat);
		this.outputDate.emit(this.selectedDate);
	}

	/**
	 * Runs whenever the user changes the input text and leaves the input (on blur event).
	 * Emits the entered value to the parent component.
	 * @param event the Event object of the given event.
	 */
	onChange(event: Event): void {
		this.selectedDate = this.enteredValue;
		this.outputDate.emit(this.enteredValue);
	}

	ngOnInit() {
		/**
		 * Configuration for datepicker
		 * @type {{locale: {format: string}; minDate: moment.Moment; maxDate: moment.Moment}}
		 */
		this.singlePickerOptions = {
			minDate: moment(this.minDate).format(SingleDatepickerComponent.dateFormat),
			maxDate: moment(this.maxDate).format(SingleDatepickerComponent.dateFormat),
			locale: {
				format: SingleDatepickerComponent.dateFormat
			},
			singleDatePicker: true,
			showDropdowns: true,
			opens: 'left'
		};
		this.selectedDate = this.enteredValue = moment(this.defaultDate).format(SingleDatepickerComponent.dateFormat);
		this.outputDate.emit(this.enteredValue);
	}
}

single-datepicker.component.html :

<div class="form-group">
	<div class="input-group" daterangepicker (selected)="selectSingleDate($event)" [options]="singlePickerOptions">
		<input class="form-control" [value]="selectedDate" (change)="onChange($event)" [(ngModel)]="enteredValue"/>
		<span class="input-group-btn">
			<a type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></a>
		</span>
	</div>
</div>

single-datepicker.component.spec.ts:

import {async, ComponentFixture, TestBed} from '@angular/core/testing';

import createSpyObj = jasmine.createSpyObj;
import {Daterangepicker} from 'ng2-daterangepicker';
import {FormsModule} from '@angular/forms';
import {SingleDatepickerComponent} from './single-datepicker.component';


describe('SingleDatepickerComponent', () => {
	let component: SingleDatepickerComponent;
	let fixture: ComponentFixture<SingleDatepickerComponent>;

	beforeEach(async(() => {
		TestBed.configureTestingModule({
			declarations: [SingleDatepickerComponent],
			imports: [Daterangepicker, FormsModule]
		}).compileComponents();
	}));

	beforeEach(() => {
		fixture = TestBed.createComponent(SingleDatepickerComponent);
		component = fixture.componentInstance;
	});

	it('should be created', () => {
		expect(component).toBeTruthy();
	});
});

And this is how I'm using it:

<app-single-datepicker [minDate]="minDate" [maxDate]="maxDate" (outputDate)="handleSelectedDate($event)" [defaultDate]="defaultDate"></app-single-datepicker>

Can't bind to 'options' since it isn't a known property of 'input'

I have been trying to get it working but has no luck. I have tried lot of example but none of them is working. Can you please suggest how to get working.
Below is the my component code

import { Component, OnInit } from '@angular/core';
import { Daterangepicker } from 'ng2-daterangepicker';
import { DaterangepickerConfig } from 'ng2-daterangepicker';

declare var moment:any;
@Component({
  selector: 'date-range-picker',
  //templateUrl: './date-range-picker.component.html',
  template: `<input type="text" name="daterangeInput" daterangepicker [options]="options" (selected)="selectedDate($event)" />`,
  styleUrls: ['./date-range-picker.component.scss']
})
export class DateRangePickerComponent {
   public daterange: any = {};

    // see original project for full list of options
    // can also be setup using the config service to apply to multiple pickers
    public options: any = {
        locale: { format: 'YYYY-MM-DD' },
        alwaysShowCalendars: false,
    };

    public selectedDate(value: any) {
        this.daterange.start = value.start;
        this.daterange.end = value.end;
        this.daterange.label = value.label;
    }
}

Always getting below error.

Uncaught Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'input'. ("<input type="text" name="daterangeInput" daterangepicker [ERROR ->][options]="options" 

Set initial date value

Hi,

I need to show the daterangepicker with one of the options selected by default. Can you please let me know how this can be achieved? I see only one '@input' for options in your component. I really need to set the initial value, otherwise need to create custom. Please let me know.

Thanks.

callback function inject

hi. how to get range label when apply date. maybe your @output selected function hasn't third parameter 'label'. please fix it or reply~

Code from http://www.daterangepicker.com/#usage

`$('input[name="daterange"]').daterangepicker(
{
    locale: {
      format: 'YYYY-MM-DD'
    },
    startDate: '2013-01-01',
    endDate: '2013-12-31'
}, 
function(start, end, label) {
    alert("A new date range was chosen: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
});`

Can't bind to 'options' since it isn't a known property of 'input'

compiler.es5.js:1694 Uncaught Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'input'. ("ass="form-group">
<input type="text" class="form-control" name="daterangeInput" daterangepicker [ERROR ->][options]="options" (selected)="datesSelected($event)" />


"): ng:///AppModule/DateRangePickerComponent.html@4:81

$(...).daterangepicker is not a function

Hi there,

I encountered that exception when I attempted to use ng2-daterangepicker at my webpack project.
I noticed this might be because ng2-daterangepicker is having its own jquery Dependency
and my project having my own jquery. This problem doesn't seem to exist when building using
System Js from your example.

Do you have any idea how to make the datepicker use the same jquery as what the project is using? Perhaps changing Jquery as PeerDependency will help?

Thanks a lot

How to reload with update new options

I want to change locale's language, so if using ngx-translate with options, ngx-translate get translate is synchronous mode, but ng2-daterangepicker can't get new options.

It's impossible to pick time "00:00" using time picker (24-hour format)

image

Config:

public reportRangeOptions = {
    timePicker: true,
    timePicker24Hour: true,
    timePickerIncrement: 1,
    locale: { format: 'YYYY-MM-DD hh:mm' },
    alwaysShowCalendars: false,
    autoApply: true,
    ranges: {
      'Last Month': [moment().subtract(1, 'month'), moment()],
      'Last 3 Months': [moment().subtract(4, 'month'), moment()],
      'Last 6 Months': [moment().subtract(6, 'month'), moment()],
      'Last 12 Months': [moment().subtract(12, 'month'), moment()],
    }
  };

npm loads an old version

Hi, 'npm i ng2-daterangepicker' loads an old version. I cant get a label for selected range. Can you update your package on npm with new build?

Two-way Data Binding with ngModal

Is there a two-way data binding with ngModal.

@Component({
    selector: 'my-app',
    template: `<input type="text" name="daterangeInput" [(ngModel)]="model" 
    />`,
})
export class AppComponent {

    public model: any = {};

}

calendar does not show after choosing a custom button

I have this html

<button md-raised-button color="primary" daterangepicker [options]="dateRangeOptions" (selected)="selectedDate($event)" *ngIf="!small">
                <md-icon>access_time</md-icon>
            </button>

where dateRangeOptions has a custom date ranges

this.dateRangeOptions.ranges = {
        'This Month': [thisMonth, moment(thisMonth).endOf('month')],
        'Last Month': [lastMonth, moment(lastMonth).endOf('month')],
        'Last 3 Months': [last3Months, moment(last3Months).add(3,'months').endOf('month')],
        'Last 6 Months': [last6Months, moment(last6Months).add(6,'months').endOf('month')],
        'Last 12 Months': [lastYear, moment(lastYear).endOf('year')]
      }

the first time I press the "date" button I get this

image

If I choose any other button apart from the custom range buttons, then everything works just fine. However, if I choose the custom button, the date range is selected, but I now cannot choose the "date" button again. It just does a ripple and shows nothing else

Can't bind to 'options' since it isn't a known property of 'input'

hey there, i followed the tutorial but can't get this component to work.
do you have any idea ?

...
import { Daterangepicker } from 'ng2-daterangepicker';
@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    TranslateModule.forRoot({
      provide: TranslateLoader,
      useFactory: (createTranslateLoader),
      deps: [Http]
    }),
    AppRoutingModule,
    SharedModule.forRoot(),
    DatePickerModule,
    Daterangepicker,
    AuthModule
  ],
  bootstrap: [AppComponent]
})
...
@Component({
  selector: 'medicine',
   template: `<input type="text" name="daterangeInput" daterangepicker [options]="options" (selected)="selectedDate($event)" />`,
})
export class MedicineComponent implements OnInit {
...

Cannot set property 'daterangepicker' of undefined

Hi,

I'm experiencing an annoying issue with the ng2-daterangepicker component. Whenever I refresh the webpage of my application or a HMR compilation occurs, I get the following error:
Exception: Call to Node module failed with error: Prerendering failed because of error: TypeError: Cannot set property 'daterangepicker' of undefined
at C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:36162:26
at Object. (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:34560:44)
at cb.parentEl (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:34561:11)
at Object. (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:34576:2)
at webpack_require (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:20:30)
at Object. (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:26136:1)
at webpack_require (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:20:30)
at Object. (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:78823:35)
at webpack_require (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:20:30)
at Object.defineProperty.value (C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2\ClientApp\dist\main-server.js:8345:27)
Current directory is: C:\Users\adaerds\Documents\Visual Studio 2017\Projects\Angular2.2

Once the error occurs, I cannot get the application to run anymore unless I comment out the datepicker imports and the dashboardcomponent it belongs to in the app.module.ts and recompile. Then after uncommenting and recompiling again it works until the next time an HMR or page refresh occurs.

I've set it up as described in the example as follows as a component used in Dashboardcomponent.

First the definitions in the application module "app.module.ts":
import { NgModule } from '@angular/core';
import { AppConfig } from './app.config';
import { AuthGuard } from './components/_guards/auth.guard';
import { ServerModule } from '@angular/platform-server';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import { Routes, RouterModule } from '@angular/router';
import { Component } from "@angular/core";
import { AppComponent } from './components/app/app.component'
import { HomeComponent } from './components/home/home.component';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { Daterangepicker } from 'ng2-daterangepicker';
....

@NgModule({
bootstrap: [AppComponent],
declarations: [ ,
DashboardComponent,
HomeComponent,
AppComponent, ....
],
imports: [
ServerModule,BrowserModule, Ng2Webstorage, FormsModule, HttpModule, JsonpModule, ChartsModule, Daterangepicker, RouterModule.forRoot([
{ path: 'home', component: HomeComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: '**', redirectTo: 'home' } ....
]),
providers: [
AppConfig,
AuthGuard,
...
],
})
export class AppModule {
}

And then as a component of dashboardcomponent.ts:
import { Component, OnInit, ViewChild, SimpleChanges} from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import * as moment from 'moment';
import { AppConfig } from '../../app.config';
import { DataService } from '../_services/data.service';
import { AlertService } from '../_services/alert.service';
import { TicketCountByMonth } from '../_models/ticketcountbymonth';
import { BaseChartDirective } from 'ng2-charts/ng2-charts'
import { DaterangepickerConfig } from 'ng2-daterangepicker';
import { DaterangePickerComponent } from 'ng2-daterangepicker';

@component({
selector: 'line-chart-demo',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css','../../shared/style.css']
})
export class DashboardComponent implements OnInit {
@ViewChild(DaterangePickerComponent)
public picker: DaterangePickerComponent;

errorMessage: string;
supportTicketsByMonth: TicketCountByMonth;

public daterange: any = {};
public fromDate: any;
public toDate: any;

constructor(private http: Http, private config: AppConfig, private alertService: AlertService, private dataService: DataService, private daterangepickerOptions: DaterangepickerConfig) {
    this.daterangepickerOptions.skipCSS = true;
    this.fromDate = moment().subtract(6, 'month').startOf('month');
    this.toDate = moment().subtract(1, 'month').endOf('month');
}

public options: any = {
    locale: { format: 'MMMM D, YYYY' },
    alwaysShowCalendars: false,
    ranges: {
        'Last 3 Months': [moment().subtract(3, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
        'Last 6 Months': [moment().subtract(6, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
        'Year To Date': [moment().startOf('year'), moment()],
        'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')],
    }
};

public selectedDate(value: any) {
    this.daterange.start = value.start;
    this.daterange.end = value.end;
    this.daterange.label = value.label;
    this.fromDate = value.start;
    this.toDate = value.end;
    this.getData(this.daterange.start, this.daterange.end);
}

/** rest of my code**/
...
}

I'm using ng2-daterangepicker version 2.0.7 and angular version 4.1.2.
I really love the look & feel of the component and couldn't find a better alternative so I would appreciate all the help to fix this issue. I'm hoping it's just a mistake on my side due to my ignorance :)

How to set two different pickers in the same template

Hey there! Firstly I want to thank you for your amazing work, it has been doing a sweet work so far and it's really simple to use, and of course, the style is gorgeous.

As for my issue, I want to clarify i'm a total beginner on angular 2 and frontend develop. I want to use two different pickers in one template. One is for estimates, and the other one is for departure and return dates.
A Single Picker, and a Range Picker, in other words.
I wanted to override the automatic loading dates of the pickers with this code.

this.picker.datePicker.setStartDate(new Date(this.Estimate.DepartureDate));
 this.picker.datePicker.setEndDate(new Date(this.Estimate.ReturnDate));

which loads in ngAfterView, but it is changing the single picker date, not the RangePicker.

Just in case, I copied this code of yours to declare picker:

 @ViewChild(DaterangePickerComponent)
    private picker: DaterangePickerComponent;

I was reading the docs and the code, but sadly I couldn't find an answer, thank you!

DaterangePickerComponent is undefined

I'm trying out the new picker methods, by following the sample from the doc.

https://github.com/evansmwendwa/ng2-daterangepicker#daterangepicker-methods

But I'm getting undefined from picker whenever I tried to use the method. I'm following the sample code given, except that my HTML is like below.

<div
    class="input-other-date-picker"
    daterangepicker
    [options]="dateOptions">
      From {{ selectedDate.start | date:'dd-MM-yyyy'}} to {{ selectedDate.end | date:'dd-MM-yyyy'}}
</div>

And the date option. The datepicker came out just fine, but I'm trying to reset the value of start date and end date when the user are done.

dateOptions: any = {
    locale: { format: 'DD-MM-YYYY' },
    startDate: this.selectedDate.start,
    endDate: this.selectedDate.end
  };

I've altered your plunk and put a button that should trigger the method and you can see the console to see the thrown error. https://embed.plnkr.co/hPpq8zrWxP4i5ORcv2CC/

If I'm implementing it the wrong way, please do let me know.

Show chosen date range label as text input value

I have a project where we have daterangepicker with some predefined ranges like Today, Yesterday, This Week, and we found that in some cases it's better to see the chosen range as a label, not as actual date.
For example when choosing Today the input should have its label as a value:
Image of datePicker

Does it make sense to have such feature, so this behaviour will be handled by passing some configuration option?

Thank you.

Way for InlineMode?

Hey,

is there a way to use this picker in inline-mode?

  • no popup
  • no inputField

just the pure picker...

Build size has doubled

Thanks for creating this component.

But before using this module my build size was 430KB, and now with ng2-daterangepicker module file size has doubled.
vendor.f0f9d51956634897db29.bundle.js 200 script home 859 KB

Please revert.

Max year for single date picker dropdown

hi,

I am implementing a single date dropdown and programmatically set the date.

When I select the year dropdown, the max year given is 5 years from the programmatically set date.
For example, if I set a date as 15 June 1985, the max year that would appear is 1990. If I set a date as 15 Sep 1975, the max year that would appear is 1980. So if I want to select the year 2000 from there, it would be impossible from the dropdown.

Is there any way for me to custom the max year for the dropdown? Do apologise if I missed it in your documentations.

dropdownpicker

dropdownpicker2

Thanks.

Year in the range options changes after selecting date range.

Hello @evansmwendwa, I was running into weird error after selecting a daterange.

When component was initialized I could see the options for all ranges has been set correct date.
Also when I select date before submitting for form selected range returns correct date.

However, after submitting a form, previous selected date ranges options changes to year 1441.
same thing happens if I select other range option and submit. I'm assuming I'm setting the value of form in wrong date format or something, but not quite sure. Could you help me identifying where is the error coming from?

Code

datefilter.component.html

<div [formGroup]="form">
    <div class="btn btn-white btn-block"
            daterangepicker
            [options]="dateOptions"
            (selected)="selectedDate($event)"
            (click)="toggleDropdown($event)">
            <span name="daterange" >{{ daterange.start | date:'yyyy-MM-dd' }} - {{ daterange.end | date:'yyyy-MM-dd' }}</span>
            <i class="fa fa-angle-down fa-fw"></i>
    </div>
    <input type="hidden" [formControlName]="'date'" [value]="daterange" />
</div>

datefilter.component.ts

...
export class FilterControlComponent {
    @ViewChild(DaterangePickerComponent) daterangepicker: DaterangePickerComponent;
    @Input() form: FormGroup;

    public daterange: any;
    public dateOptions: any;

    constructor() {

    this.dateOptions = {
      locale: {format: 'YYYY-MM-DD'},
      ranges: {
            'Today': [moment().startOf('day'), moment().endOf('day')],
            'Yesterday': [moment().subtract(1, 'day'), moment().subtract(1, 'day')],
            'Last 7 Days': [moment().subtract(6, 'days'), moment()],
            'Last 30 Days': [moment().subtract(29, 'days'), moment()],
            'This Month': [moment().startOf('month'), moment()],
            'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
            'Last 3 Months': [moment().subtract(4, 'month').startOf('day'), moment().endOf('day')],
            'Last 6 Months': [moment().subtract(6, 'month').startOf('day'), moment().endOf('day')],
            'Last 12 Months': [moment().subtract(12, 'month').startOf('day'), moment().endOf('day')],
          }
        };


        this.daterange = {
          start: moment(),
          end: moment()
        };
    }
    public selectedDate(value: any) {
        this.daterange.start = value.start;
        this.daterange.end = value.end;
        this.form.controls['date'].setValue(this.daterange);

        console.log('selectedDate', value, this.daterangepicker, this.dateOptions.ranges, moment());
      }
}

Screenshot of console.log in selectedDate($event){}

Before submitting form
screen shot 2017-08-02 at 10 25 44 am
year of Last 7 Days are correct

After submitting form
screen shot 2017-08-02 at 10 26 44 am
year of Last 7 Days became 1441

Is there a way to use 'isInvalidDate'

Hello there!
I would like to use "isInvalidDate", wondering if it is possible. And if so, could you please share some code examples how to disable date(s) (In addition to min-date and max-date options)

SystemJS

First off, great package! Super useful especially since other angular2 bootstrap implementations don't seem to have the date-range

I saw your note:
"I have not tested usage with system js for now, currently working on Angular 2 Webpack setup, will update after thorough testing."

And wanted to report back my findings: your dependencies right now are a little rough around the edges, but overall this can be jammed into SystemJS with one exception (at least as far as our implementation seems to support): the css file you're including. The require statement in daterangepicker.component.ts for the css file is causing issues as our importer continues to try and flag it as a js file. There may be work arounds, but thats as far as I was able to get in the amount of time I dedicated to look into this. Do you have any suggestions/ways to implement without having the css required?

Opening DateRangePicker outside component

I am trying to open date range picker from a modal component. But Its opening the calendars outside the modal (in the background) and when using custom style instead of bootstrap.css its not opening at all.

Further, on starting the application a small dialogbox with apply/cancel buttons and the date range inputs are visible. I want it to be visible only after I call for it.

Overriding styles does not work

Hi,

I am trying to customize the styles of the date range picker in my main CSS file.
However, the generic styles are injected after the styles contained in the main.css.

This is my .angular-cli.json configuration:

"styles": [
    "assets/css/main.css"
],

Any suggestions?

Thanks,

Fernando

Only show placeholder in date picker and after select date, date will display.

Hi, I have does not enter start date but default show current date. I have use single date picker. Now my requirement is:-
Show input filed with placeholder. After click on input filed date calendar will be open then select any date so show in input field.
Please tell us how is it possible.
My options is:-
this.dateOptions = { locale: { format: "MM/DD/YYYY" }, singleDatePicker: true };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.