项目作者: changhuixu

项目描述 :
Angular components for Date Range Picker and Date Picker using ng-bootstrap
高级语言: TypeScript
项目地址: git://github.com/changhuixu/date-range-picker.git
创建时间: 2018-03-20T21:59:31Z
项目社区:https://github.com/changhuixu/date-range-picker

开源协议:

下载


DateRangePicker

An Angular library of Date Range Picker. Dependencies: Angular, ng-bootstrap, Bootstrap >4 (css)

Since v19.0.0, this library is only compatible with Angular >=19 and ng-bootstrap >=18.

Since v7.0.0, this library is only compatible with Angular >=13 and ng-bootstrap >=12.

Since v6.0.0, this library is only compatible with Angular >=13 and ng-bootstrap >=11.

Since v5.0.0, this library is only compatible with Angular >=12 and ng-bootstrap >=10.

Since v4.0.0, this library is only compatible with Angular >=10 and ng-bootstrap >=7.

Since v3.0.0, this library requires @angular/localize, due to updates in Angular 9 and ng-bootstrap 6.

Build Status
@uiowa/date-range-picker"">npm

  1. npm i @uiowa/date-range-picker

Demo

date range picker demo

Models

  • DateRange: an object represents a date range, includes start date and end date. e.g.,
  1. const d1 = new DateRange();
  2. const d2 = new DateRange(new Date(), new Date(2018, 9, 10));
  3. const d3 = DateRange.nextTwoWeeks();
  4. const d4 = DateRange.nextDays(10);
  5. const d5 = DateRange.nextMonth();

Components

  • <date-picker></date-picker>: a wrapper of ng-bootstrap date picker

  • <date-range-picker></date-range-picker>: a date range picker based on ng-bootstrap

Usage

  1. import { DateRangePickerModule } from '@uiowa/date-range-picker';
  2. @NgModule({
  3. declarations: [AppComponent],
  4. imports: [
  5. ...,
  6. DateRangePickerModule,
  7. ...
  8. ],
  9. providers: [],
  10. bootstrap: [AppComponent]
  11. })
  1. // in your component.html
  2. <date-range-picker
  3. [(dateRange)]="dateRange"
  4. [maxDate]="maxDate"
  5. ></date-range-picker>
  6. <date-picker [(date)]="date"></date-picker>
  1. import { Component, OnInit } from '@angular/core';
  2. import { DateRange } from '@uiowa/date-range-picker';
  3. @Component({
  4. ...
  5. })
  6. export class AppComponent implements OnInit {
  7. dateRange = new DateRange();
  8. maxDate = new Date();
  9. date: Date;
  10. ngOnInit(): void {
  11. this.maxDate.setDate(this.maxDate.getDate() + 20);
  12. }
  13. }