在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):fetrarij/ngx-daterangepicker-material开源软件地址(OpenSource Url):https://github.com/fetrarij/ngx-daterangepicker-material开源编程语言(OpenSource Language):TypeScript 62.1%开源软件介绍(OpenSource Introduction):ngx-daterangepicker-material
This Demo: https://fetrarij.github.io/ngx-daterangepicker-material/ Versions
InstallationInstall the plugin from npm:
import NgxDaterangepickerMd in your module: ...
import { FormsModule } from '@angular/forms';
import { NgxDaterangepickerMd } from 'ngx-daterangepicker-material';
import { App } from './app';
@NgModule({
imports: [
... ,
FormsModule,
NgxDaterangepickerMd.forRoot()
],
declarations: [App],
bootstrap: [App]
})
export class AppModule {} Usage exampleHtml: <input type="text" ngxDaterangepickerMd [(ngModel)]="selected" class="form-control"/> Typescript: selected: {startDate: Dayjs, endDate: Dayjs}; with some options:Html: <input type="text" matInput
ngxDaterangepickerMd
[locale]="{applyLabel: 'ok', format: 'DD-MM-YYYY'}"
startKey="start"
endKey="end"
[(ngModel)]="selected"
name="daterange"/> Typescript: selected: {start: Dayjs, end: Dayjs}; You can play with our online demo here and browse our demo code here. Inline usageYou can use the component directly in your templates, which will set its <ngx-daterangepicker-material (choosedDate)="choosedDate($event)">
</ngx-daterangepicker-material> Available optionsautoApply, showDropdowns, singleDatePicker, showWeekNumbers, showISOWeekNumbers, alwaysShowCalendars, showClearButton, showCancel
isCustomDate
isInvalidDate
isTooltipDate
minDate, maxDate
dateLimit
locale
{
format: 'MM/DD/YYYY', // could be 'YYYY-MM-DDTHH:mm:ss.SSSSZ'
displayFormat: 'MM/DD/YYYY', // default is format value
direction: 'ltr', // could be rtl
weekLabel: 'W',
separator: ' To ', // default is ' - '
cancelLabel: 'Cancel', // detault is 'Cancel'
applyLabel: 'Okay', // detault is 'Apply'
clearLabel: 'Clear', // detault is 'Clear'
customRangeLabel: 'Custom range',
daysOfWeek: dayjs.weekdaysMin(),
monthNames: dayjs.monthsShort(),
firstDay: 1 // first day is monday
} Check here for setting the global locale startKey and endKeyTheses 2 options are for the key you want for the value, default are Specifiyng example: <input type="text" ngxDaterangepickerMd startKey="start" endKey="end" [(ngModel)]="model"> the model we got would be: ranges(object) Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range. As an example: <input type="text" ngxDaterangepickerMd startKey="start" endKey="end" [ranges]="ranges" [(ngModel)]="model"> ranges: any = {
'Today': [dayjs(), dayjs()],
'Yesterday': [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
'Last 7 Days': [dayjs().subtract(6, 'days'), dayjs()],
'Last 30 Days': [dayjs().subtract(29, 'days'), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
'Last Month': [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')]
} Other options with rangesYou can use bellow options when using the ranges. The default are
Open datepicker from outsideIt is possible to open datepicker from outside. You should create an input with attached datepicker directive and a button with "ngx-daterangepicker-action" class (to prevent triggering of clickOutside). <input
ngxDaterangepickerMd
[closeOnAutoApply]="true"
[autoApply]="true"
[singleDatePicker]="true"
[linkedCalendars]="true"
[(ngModel)]="selected"
(datesUpdated)="datesUpdated($event)"
class="datepicker-calendar-icon">
<a class="ngx-daterangepicker-action" (click)="openDatepicker()">
Open
</a> ...
@ViewChild(DaterangepickerDirective, { static: false }) pickerDirective: DaterangepickerDirective;
...
...
openDatepicker() {
this.pickerDirective.open();
} TimepickerYou have to set the attribute You can use theses options:
Customisation
Positioning
Available events(rangeClicked)
(datesUpdated)
(clearClicked)
Global localeFor setting the global locale, pass this object to NgxDaterangepickerMd.forRoot(). eg:
DevelopmentPrepare your environmentInstall local dependencies: Development serverRun Open TestsRun LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论