steve-ferrero / ng-pick-datetime

A datepicker for angular
http://www.web-atrio.com/SSII/developpement-2D-3D
MIT License
3 stars 3 forks source link

Angular Date Time Picker

Angular date time picker - Angular reusable UI component

Important

This package supports Angular 4

*Source: (https://github.com/DanielYKPan/date-time-picker)

Updates

Updates Web-Atrio

Other Similar Projects

Description

Simple Angular date time picker. Online demo is here. This picker is responsive design, so feel free to try it in your desktops, tablets and mobile devices. This picker uses MomentJS

Installation

To install this component, follow the procedure:

  1. Install with npm:npm install @web-atrio/date-time-picker --save
  2. Add DateTimePickerModule import to your @NgModule like example below

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { MyTestApp } from './my-test-app';
    
    import { DateTimePickerModule } from '@web-atrio/date-time-picker';
    
    @NgModule({
        imports:      [ BrowserModule, DateTimePickerModule ],
        declarations: [ MyTestApp ],
        bootstrap:    [ MyTestApp ]
    })
    export class MyTestAppModule {}
  3. This picker use MomentJS. Remember to load MomentJS when you load your project from webpack or systemjs.**
  4. If you are using systemjs package loader add the following ng-pick-datetime properties to the System.config:

    (function (global) {
        System.config({
            paths: {
                'npm:': 'node_modules/'
            },
            map: {
                // Other components are here...
    
                'ng-pick-datetime': 'npm:ng-pick-datetime',
                'moment': 'npm:moment',
            },
            packages: {
                // Other components are here...
    
                // the picker
                'ng-pick-datetime': {
                    main: 'picker.bundle.js',
                    defaultExtension: 'js'
                },
                // momentJS
                'moment': {
                    main: 'moment.js',
                    defaultExtension: 'js'
                },
            }
        });
    })(this);

Usage

Use the following snippet inside your template. For example:

<input [ngModel]="momentValue | date: 'short'" [(dateTimePicker)]="momentValue" readonly />

Or:

<input [ngModel]="momentValue | date: 'short'" [dateTimePicker]="momentValue" (dateTimePickerChange)="setMoment($event)" readonly />
public setMoment(moment: any): any {
    this.momentValue = moment;
    // Do whatever you want to the return object 'moment'
}

Demo

Online demo is here

License

Author