Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ion2-calendar
Advanced tools
English is not my native language; please excuse typing errors. 中文文档
live demo click me.
$ npm install ion2-calendar moment --save
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
...
import { CalendarModule } from "ion2-calendar";
@NgModule({
declarations: [
MyApp,
...
],
imports: [
IonicModule.forRoot(MyApp),
CalendarModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
]
})
export class AppModule {}
<ion-calendar [(ngModel)]="date"
(onChange)="onChange($event)"
[format]="'YYYY-MM-DD'">
</ion-calendar>
import { Component } from '@angular/core';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
date: string;
constructor() { }
onChange($event) {
console.log($event);
}
...
}
<ion-calendar [(ngModel)]="dateRange"
[options]="optionsRange"
[format]="'YYYY-MM-DD'">
</ion-calendar>
import { Component } from '@angular/core';
import { CalendarComponentOptions } from 'ion2-calendar'
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
dateRange: { from: string; to: string; };
optionsRange: CalendarComponentOptions = {
pickMode: 'range'
};
constructor() { }
...
}
<ion-calendar [(ngModel)]="dateMulti"
[options]="optionsMulti"
[format]="'YYYY-MM-DD'">
</ion-calendar>
import { Component } from '@angular/core';
import { CalendarComponentOptions } from 'ion2-calendar'
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
dateMulti: string[];
optionsMulti: CalendarComponentOptions = {
pickMode: 'multi'
};
constructor() { }
...
}
Name | Type | Default | Description |
---|---|---|---|
options | CalendarComponentOptions | null | options |
format | string | 'YYYY-MM-DD' | value format |
Name | Type | Default | Description |
---|---|---|---|
from | Date | new Date() | start date |
to | Date | 0 (Infinite) | end date |
color | string | 'primary' | 'primary', 'secondary', 'danger', 'light', 'dark' |
pickMode | string | single | 'multi', 'range', 'single' |
disableWeeks | Array | [] | week to be disabled (0-6) |
monthFormat | string | 'MMM yyyy' | month title format |
weekdays | Array | ['S', 'M', 'T', 'W', 'T', 'F', 'S'] | weeks text |
weekStart | number | 0 (0 or 1) | set week start day |
daysConfig | Array<DaysConfig> | [] | days configuration |
Import ion2-calendar in component controller.
import { Component } from '@angular/core';
import { ModalController } from 'ionic-angular';
import { CalendarModal, CalendarModalOptions, DayConfig } from "ion2-calendar";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(
public modalCtrl: ModalController,
) { }
openCalendar() {
const options: CalendarModalOptions = {
title: 'BASIC',
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
})
}
}
Set pickMode to 'range'.
openCalendar() {
const options: CalendarModalOptions = {
pickMode: 'range',
title: 'RANGE'
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
});
}
Set pickMode to 'multi'.
openCalendar() {
const options = {
pickMode: 'multi',
title: 'MULTI'
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
})
}
Use index eg: [0, 6]
denote Sunday and Saturday.
openCalendar() {
const options: CalendarModalOptions = {
disableWeeks: [0, 6]
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
});
}
openCalendar() {
const options: CalendarModalOptions = {
monthFormat: 'yyyy 年 MM 月 ',
weekdays: ['天', '一', '二', '三', '四', '五', '六'],
weekStart: 1,
defaultDate: new Date()
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
});
}
Configure one day.
openCalendar() {
let _daysConfig: DayConfig[] = [];
for (let i = 0; i < 31; i++) {
_daysConfig.push({
date: new Date(2017, 0, i + 1),
subTitle: `$${i + 1}`
})
}
const options: CalendarModalOptions = {
from: new Date(2017, 0, 1),
to: new Date(2017, 11.1),
daysConfig: _daysConfig
};
let myCalendar = this.modalCtrl.create(CalendarModal, {
options: options
});
myCalendar.present();
myCalendar.onDidDismiss(date => {
console.log(date);
});
}
Name | Type | Default | Description |
---|---|---|---|
from | Date | new Date() | start date |
to | Date | 0 (Infinite) | end date |
title | string | 'CALENDAR' | title |
color | string | 'primary' | 'primary', 'secondary', 'danger', 'light', 'dark' |
defaultScrollTo | Date | none | let the view scroll to the default date |
defaultDate | Date | none | default date data, apply to single |
defaultDates | Array | none | default dates data, apply to multi |
defaultDateRange | { from: Date, to: Date } | none | default date-range data, apply to range |
cssClass | string | '' | Additional classes for custom styles, separated by spaces. |
canBackwardsSelected | boolean | false | can backwards selected |
pickMode | string | single | 'multi', 'range', 'single' |
disableWeeks | Array | [] | week to be disabled (0-6) |
closeLabel | string | CANCEL | cancel button label |
doneLabel | string | DONE | done button label |
closeIcon | boolean | false | show cancel button icon |
doneIcon | boolean | false | show done button icon |
monthFormat | string | 'MMM yyyy' | month title format |
weekdays | Array | ['S', 'M', 'T', 'W', 'T', 'F', 'S'] | weeks text |
weekStart | number | 0 (0 or 1) | set week start day |
daysConfig | Array<DaysConfig> | [] | days configuration |
pickMode | Type |
---|---|
single | { date: CalendarResult } |
range | { from: CalendarResult, to: CalendarResult } |
multi | Array<CalendarResult> |
Name | Type | Default | Description |
---|---|---|---|
cssClass | string | '' | separated by spaces |
date | Date | required | configured days |
marked | boolean | false | highlight color |
disable | boolean | false | disable |
title | string | none | displayed title eg: 'today' |
subTitle | string | none | subTitle subTitle eg: 'New Year\'s' |
Name | Type |
---|---|
time | number |
unix | number |
dateObj | Date |
string | string |
years | number |
months | number |
date | number |
cd ./dev
npm install
npm run ionic:serve
# do something in ./dev/src/components/ion2-calendar
cd ./
npm install
npm run build
FAQs
A date picker component for ionic2
The npm package ion2-calendar receives a total of 1,078 weekly downloads. As such, ion2-calendar popularity was classified as popular.
We found that ion2-calendar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.