
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
yourdatepicker
Advanced tools
Angular 2 date picker - Angular2 reusable UI component
Simple Angular2 date picker. Online demo is here
To install this component to an external project, follow the procedure:
npm install yourdatepicker --save
Add yourdatepickerModule import to your @NgModule like example below
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyTestApp } from './my-test-app';
// If you are using webpack package loader import the yourdatepickerModule from here:
import { yourdatepickerModule } from 'yourdatepicker';
// If you are using systemjs package loader import the yourdatepickerModule from here:
import { yourdatepickerModule } from 'yourdatepicker/dist/my-date-picker.module';
@NgModule({
imports: [ BrowserModule, yourdatepickerModule ],
declarations: [ MyTestApp ],
bootstrap: [ MyTestApp ]
})
export class MyTestAppModule {}
Use the following snippet inside your template:
<my-date-picker [options]="yourdatepickerOptions"
(dateChanged)="onDateChanged($event)"></my-date-picker>
Mandatory attributes:
Optional attributes:
If you are using systemjs package loader add the following yourdatepicker properties to the System.config:
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
// Other components are here...
'yourdatepicker': 'npm:yourdatepicker',
},
packages: {
// Other components are here...
yourdatepicker: {
defaultExtension: 'js'
}
}
});
})(this);
Value of the options attribute is a javascript object. It can contain the following properties.
Option | Default | Description |
---|---|---|
dayLabels | {su: 'Sun', mo: 'Mon', tu: 'Tue', we: 'Wed', th: 'Thu', fr: 'Fri', sa: 'Sat'} | Day labels visible on the selector. |
monthLabels | { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } | Month labels visible on the selector. |
dateFormat | yyyy-mm-dd | Date format on the selection area and the callback. For example: dd.mm.yyyy, yyyy-mm-dd, dd mmm yyyy (mmm = Month as a text) |
showTodayBtn | true | Show 'Today' button on calendar. |
todayBtnTxt | Today | Today button text. Can be used if showTodayBtn = true. |
firstDayOfWeek | mo | First day of week on calendar. One of the following: mo, tu, we, th, fr, sa, su |
sunHighlight | true | Sunday red colored on calendar. |
markCurrentDay | true | Is current day (today) marked on calendar. |
editableMonthAndYear | true | Is month and year labels editable or not. |
minYear | 1000 | Minimum allowed year in calendar. Cannot be less than 1000. |
maxYear | 9999 | Maximum allowed year in calendar. Cannot be more than 9999. |
disableUntil | no default value | Disable dates backward starting from the given date. For example: {year: 2016, month: 6, day: 26} |
disableSince | no default value | Disable dates forward starting from the given date. For example: {year: 2016, month: 7, day: 22} |
disableDays | no default value | Disable single days one by one. Array of disabled days. For example: [{year: 2016, month: 11, day: 14}, {year: 2016, month: 1, day: 15] |
disableDateRange | no default value | Disable a date range from begin to end. For example: {begin: {year: 2016, month: 11, day: 14}, end: {year: 2016, month: 11, day: 20} |
disableWeekends | false | Disable weekends (Saturday and Sunday). |
inline | false | Show yourdatepicker in inline mode. |
showClearDateBtn | true | Is clear date button shown or not. Can be used if inline = false. |
height | 34px | yourdatepicker height without selector. Can be used if inline = false. |
width | 100% | yourdatepicker width. Can be used if inline = false. |
selectionTxtFontSize | 18px | Selection area font size. Can be used if inline = false. |
alignSelectorRight | false | Align selector right. Can be used if inline = false. |
indicateInvalidDate | true | If user typed date is not same format as dateFormat, show red background in the selection area. Can be used if inline = false. |
showDateFormatPlaceholder | false | Show value of dateFormat as placeholder in the selection area if a date is not selected. Can be used if inline = false. |
customPlaceholderTxt | empty string | Show custom string in the selection area if a date is not selected. Can be used if showDateFormatPlaceholder = false and inline = false. |
componentDisabled | false | Is selection area input field and buttons disabled or not (input disabled flag). Can be used if inline = false. |
editableDateField | true | Is selection area input field editable or not (input readonly flag). Can be used if inline = false. |
inputValueRequired | false | Is selection area input field value required or not (input required flag). Can be used if inline = false. |
showSelectorArrow | true | Is selector (calendar) arrow shown or not. Can be used if inline = false. |
showInputField | true | Is selection area input field shown or not. If not, just show the icon. Can be used if inline = false. |
yourdatepickerOptions = {
todayBtnTxt: 'Today',
dateFormat: 'yyyy-mm-dd',
firstDayOfWeek: 'mo',
sunHighlight: true,
height: '34px',
width: '260px',
inline: false,
disableUntil: {year: 2016, month: 8, day: 10},
selectionTxtFontSize: '16px'
};
An ISO 639-1 language code can be provided as shorthand for several of the options listed above. Currently supported languages: en, fr, ja, fi, es, hu, sv, nl, ru, no, tr, pt-br, de, it, pl, my, sk and sl. If the locale attribute is used it overrides dayLabels, monthLabels, dateFormat, todayBtnTxt, firstDayOfWeek and sunHighlight properties from the options.
Provide the initially chosen date that will display both in the text input field and provide the default for the popped-up selector.
Type of the selDate attribute can be a string or an IMyDate object.
If selDate is not specified, when the datepicker is opened, it will ordinarily default to selecting the current date. If you would prefer a different year and month to be the default for a freshly chosen date picking operation, specify a [defaultMonth] attribute.
Value of the [defaultMonth] attribute is a string which contain year number and month number separated by delimiter. The delimiter can be any special character. For example the value of the [defaultMonth] attribute can be: 2016.08, 08-2016, 08/2016.
called when the date is selected, removed or input field typing is valid
event parameter:
Example of the dateChanged callback:
onDateChanged(event:any) {
console.log('onDateChanged(): ', event.date, ' - jsdate: ', new Date(event.jsdate).toLocaleDateString(), ' - formatted: ', event.formatted, ' - epoc timestamp: ', event.epoc);
}
called when the value change in the input field, date is selected or date is cleared (can be used in validation, returns true or false indicating is date valid or not in the input field)
event parameter:
Example of the input field changed callback:
onInputFieldChanged(event:any) {
console.log('onInputFieldChanged(): Value: ', event.value, ' - dateFormat: ', event.dateFormat, ' - valid: ', event.valid);
}
called when the calendar view change (year or month change)
event parameter:
values of the weekday property are same as values of the firstDayOfWeek option
Example of the calendar view changed callback:
onCalendarViewChanged(event:any) {
console.log('onCalendarViewChanged(): Year: ', event.year, ' - month: ', event.month, ' - first: ', event.first, ' - last: ', event.last);
}
The styles of the component can be changed by overriding the styles.
Create a separate stylesheet file which contain the changed styles. Then import the stylesheet file in the place which is after the place where the component is loaded.
At first fork and clone this repo.
Install all dependencies:
Build dist and npmdist folders and execute tslint:
Execute unit tests and coverage (output is generated to the test-output folder):
Run sample application:
Build a local npm installation package:
Install local npm package to your project:
Firefox (latest)
Chrome (latest)
Chromium (latest)
Edge
IE11
Safari
FAQs
Angular2 date picker
We found that yourdatepicker 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.