New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng2-daterangepicker

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-daterangepicker

Angular 2 DaterangePicker component

1.0.4
Source
npm
Version published
Weekly downloads
4.7K
8.72%
Maintainers
1
Weekly downloads
 
Created
Source

ng2-daterangepicker

This is a port of the popular Daterange Picker for Bootstrap now optimized for easy use as an importable Angular 2 Module and installable using npm.

Installation

npm install ng2-daterangepicker --save

Usage

Add Bootstrap to your project's index.html or include in your workflow

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

import the Daterangepicker module in your application module

import { Daterangepicker } from 'ng2-daterangepicker';

@NgModule({
    imports: [Daterangepicker]
})

Use the directive in your component by passing in options {} and consuming the selected event. See this project's src/app/app.component.ts for a full usage example

@Component({
    selector: 'my-app',
    template: `<input type="text" name="daterangeInput" daterangepicker [options]="options" (selected)="selectedDate($event)" />`,
})
export class AppComponent {

    public daterange: any = {};

    private selectedDate(value: any) {
        daterange.start = value.start;
        daterange.end = value.end;
    }
}

You can pass global settings that can be overloaded by the options object in the daterangepicker instances. Use the DaterangepickerConfig service to do so. The service provider is set in the daterangepicker module.

import { DaterangepickerConfig } from 'ng2-daterangepicker';

@Component({
    selector:'my-app',
    template:'<h3>Component Template</h3>'
})
export class AppComponent {

    constructor(private daterangepickerOptions: DaterangepickerConfig) {
        this.daterangepickerOptions.settings = {
            locale: { format: 'YYYY-MM-DD' },
            alwaysShowCalendars: false
        };
    }
}

For a list of the available daterangepicker options and samples visit the original site http://www.daterangepicker.com/

Note:

  • This Component is still under development and I will be adding more features.
  • This Component depends on jQuery, Moment.js and Bootstrap to work correctly.
  • I have not tested usage with system js for now, currently working on Angular 2 Webpack setup, will update after thorough testing.
  • You are encouraged to contribute

FAQs

Package last updated on 26 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts