Giter Club home page Giter Club logo

angular-moment-picker's Introduction

Angular Moment Picker

Join the chat at https://gitter.im/indrimuska/angular-moment-picker

NPM version NPM downloads MIT License

Check out the homepage at http://indrimuska.github.io/angular-moment-picker/.

Angular Moment Picker is a native AngularJS directive for date and time picker that uses Moment.js and does not require jQuery.

Angular Moment Picker demo

Installation

Get Angular Moment Picker from npm, bower or git:

  npm install angular-moment-picker
bower install moment-picker
  git clone   https://github.com/indrimuska/angular-moment-picker.git

Include style and script in your page:

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment-with-locales.js"></script>
<script src="//cdn.rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.min.js"></script>
<link href="//cdn.rawgit.com/indrimuska/angular-moment-picker/master/dist/angular-moment-picker.min.css" rel="stylesheet">

Add moment-picker dependency to your module:

var myApp = angular.module('myApp', ['moment-picker']);

Provide the attribute to your element:

<div moment-picker="myDate"> {{ myDate }} </div>

Demo

Check out the demo page at http://indrimuska.github.io/angular-moment-picker/.

The views

Year view Month view Day view Hour view Minute view
Year view Month view Day view Hour view Minute view

Options

To configure Angular Moment Picker you have to append to your block or your input the attribute options you want to set.

<div moment-picker="ctrl.birthday" locale="fr" format="LL">
    Mon anniversaire est le {{ ctrl.birthday }}
</div>
Property Default Description
moment-picker Two-way bindable model property, required to use the directive.
locale "en" Locale code. 1
format "L LT" Format of the output value and min/max date. 1
min-view "year" Minimum navigable view.
max-view "hour" Maximum navigable view.
start-view "year" Initial view when the picker is open.
min-date Two-way bindable property representing the minimum selectable date in the same format of the value.
max-date Two-way bindable property representing the maximum selectable date in the same format of the value.

momentPickerProvider

Angular Moment Picker comes out with its own provider, in order to define your own configuration for all the pickers in your app.

angular
    .module('myApp', ['moment-picker'])
    .config(['momentPickerProvider', function (momentPickerProvider) {
        momentPickerProvider.options({
            /* ... */
        });
    }]);
Property Default Description
locale "en" Locale code. 1
format "L LTS" Format of the output value and min/max date. 1
min-view "year" Minimum navigable view.
max-view "hour" Maximum navigable view.
start-view "year" Initial view when opening the picker.
left-arrow "&larr;" Left arrow string (HTML allowed).
right-arrow "&rarr;" Right arrow string (HTML allowed).
months-format "MMM" Months format in year view.
days-format "D" Days format in month view.
hours-format "HH:[00]" Hours format in day view.
minutes-format 2 Minutes format in hour view.
minutes-step 5 Step between each visible minute in hour view.
seconds-format "ss" Seconds format in minute view.
seconds-step 1 Step between each visible second in minute view.

Notes

  1. Locale codes and format tokens are available at http://momentjs.com/.
  2. Locale format LT without meridiem part (AM/PM, am/pm).

Builder

Try the online Angular Moment Picker Builder:

http://indrimuska.github.io/angular-moment-picker/#builder.

License

Copyright (c) 2015 Indri Muska. Licensed under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.