Git Product home page Git Product logo

angularjs-datetime-picker's Introduction

Simple DateTime Picker For AngularJS

No JQuery, No Bootstrap, Just AngularJS (ver. 1.3+)

DEMO Imgur

To Get Started

For Bower users,

$ bower install angularjs-datetime-picker

  1. Include angularjs-datetime-picker.js and angularjs-datetime-picker.css

     <link rel="stylesheet" href="angularjs-datetime-picker.css" />
     <script src="angularjs-datetime-picker.js"></script>
    
  2. add it as a dependency

     var myApp = angular.module('myApp', ['angularjs-datetime-picker']);
    
  3. Use it

     <input datetime-picker ng-model="model" />
    

Attributes

  • date-format: optional, date format e.g. 'yyyy-MM-dd'
  • year: optional, year selected, e.g. 2015
  • month: optional, month selected, e.g. 5
  • day: optiona, day selected, e.g. 31
  • hour: optional, hour selected, 23
  • minute: optional, minute selected, 59
  • date-only: optional, if set, timepicker will be hidden
  • future-only: optional, if set, forces validation errors on dates earlier than now

Examples

<input ng-model="date1" datetime-picker date-only />

<input ng-model="date1" datetime-picker date-only future-only />

<input ng-model="date2" datetime-picker date-format="yyyy-MM-dd" date-only />

<input ng-model="date3" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" />

<input ng-model="date4" datetime-picker hour="23" minute='59'/>

<input ng-model="date5" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" year="2014" month="12" day="31" />

angularjs-datetime-picker's People

Contributors

allenhwkim avatar backnol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angularjs-datetime-picker's Issues

How to restrict past 30 days ?

I have added a class "selectable" to disable visibility of particular date item like this.

ng-class="{',
        '        selectable: getVisibility(today, mv, day),',
        '        selected: (day == selectedDay),',
        '        today: (today == (mv.year + \'-\' + (mv.month + 1) + \'-\' + day)),',
        '        weekend: (mv.leadingDays.length + day)%7 == 1 || (mv.leadingDays.length + day)%7 == 0',
        '      }"

and the function like this

scope.getVisibility = function(d, mv, day) {
                if(scope.cusVal){
                    var temp = new Date(d);var futureDates = new Date(d);
                    temp.setDate(temp.getDate()-window.cusVal);
                    futureDates.setDate(futureDates.getDate());
                    return (temp <= new Date(mv.year + '-' + (mv.month + 1) + '-' + day) ? true : false) && (futureDates >= new Date(mv.year + '-' + (mv.month + 1) + '-' + day) ? true : false);
                }else if(!scope.cusVal){
                    return (new Date(d) >= new Date(mv.year + '-' + (mv.month + 1) + '-' + day) ? true : false);
                } else {
                    return (new Date(d) <= new Date(mv.year + '-' + (mv.month + 1) + '-' + day) ? true : false);
                }
            }

Currenlty, I am disabling either past dates or future dates but not specific date range.
How can I make visible only the past 30 days?

How to toggle the popup with a button ?

Is there a way to toggle the popup by clicking a button on the side of an nput ? I tried using the directive on a input-group with same ng-model name as the input. It works but pop position is off which is expected as it shows relative to clicked element.
datetimepop

Is there a way around this ?

Datepicker control hides behind the controls

Added z-index to fix this issue. Kindly look into it.

issue

Code: .
angularjs-datetime-picker {
color: #333;
font: normal 14px sans-serif;
border: 1px solid #ddd;
display: inline-block;
background: #fff;
z-index: 1000;
}

Thanks

min max attribute for time

  • in addition to date-only, add time-only
  • with time-only, date is not selectable
  • range slide should not move the time not selectable

Failed to instantiate module publicApp due to: [$injector:modulerr] Failed to instantiate module angularjs-datetime-picker due to: [$injector:nomod] Module 'angularjs-datetime-picker' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Error: [$injector:modulerr] Failed to instantiate module publicApp due to:
[$injector:modulerr] Failed to instantiate module angularjs-datetime-picker due to:
[$injector:nomod] Module 'angularjs-datetime-picker' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.5/$injector/nomod?p0=angularjs-datetime-picker
minErr/<@http://localhost:3000/lib/angular/angular.js:68:12
module/<@http://localhost:3000/lib/angular/angular.js:2070:1
ensure@http://localhost:3000/lib/angular/angular.js:1994:38
module@http://localhost:3000/lib/angular/angular.js:2068:1
loadModules/<@http://localhost:3000/lib/angular/angular.js:4564:22
forEach@http://localhost:3000/lib/angular/angular.js:322:11
loadModules@http://localhost:3000/lib/angular/angular.js:4548:5
loadModules/<@http://localhost:3000/lib/angular/angular.js:4565:40
forEach@http://localhost:3000/lib/angular/an

min & max date

I have not seen any information regarding minimum and maximum date. Is it possible to set the minimum and maximum date?

Clicking on empty input throws immediate exception.

angular.js:78 Uncaught Error: [$parse:syntax] Syntax Error: Token ':' not a primary expression at column 1 of the expression [::dayOfWeek.firstLetter] starting at [::dayOfWeek.firstLetter].
http://errors.angularjs.org/1.2.24/$parse/syntax?p0=%3A&p1=not%20a%20primar…ression&p2=1&p3=%3A%3AdayOfWeek.firstLetter&p4=%3A%3AdayOfWeek.firstLetter(anonymous function) @ angular.js:78throwError @ angular.js:10544primary @ angular.js:10519unary @ angular.js:10767multiplicative @ angular.js:10750additive @ angular.js:10741relational @ angular.js:10732equality @ angular.js:10723logicalAND @ angular.js:10714logicalOR @ angular.js:10702ternary @ angular.js:10686assignment @ angular.js:10669expression @ angular.js:10665filterChain @ angular.js:10631statements @ angular.js:10610parse @ angular.js:10494(anonymous function) @ angular.js:11305$interpolate @ angular.js:8782addTextInterpolateDirective @ angular.js:6959collectDirectives @ angular.js:6208compileNodes @ angular.js:6039compileNodes @ angular.js:6055compile @ angular.js:5976applyDirectivesToNode @ angular.js:6386compileNodes @ angular.js:6043compileNodes @ angular.js:6055compileNodes @ angular.js:6055compile @ angular.js:5976DatetimePickerCtrl.openDatetimePicker @ angularjs-datetime-picker.js:60open @ angularjs-datetime-picker.js:23(anonymous function) @ angularjs-datetime-picker.js:326

Project dead?

@allenhwkim what is the status of this project? No commits made in 2016
Any plans for future? Maybe get more maintainers to help with pull requests?

ie 11 not working

in ie 11 the popup goes in bottom left of the page and become unresponsive and can't be closed

Getting: Uncaught Error

I get following error when clicked on the text box

Uncaught Error: [ng:areq] http://errors.angularjs.org/1.4.8/ng/areq?p0=scope&p1=required

Can you please help?

Edited:

I tried to debug it and found out that this happens when debugInfoEnabled is set to false.

$compileProvider.debugInfoEnabled(false);

Is there a workaround for this?

Also i think it will be better to add a z-index for the element. thanks

build tests

  • move index.html to test.html
  • test al e2e cases for test.html

No picker on modal

I have this code inside modal(made by jquery, not angular-bootstrap lib)
<div class='input-group date datetimepicker'> <input type='text' class="form-control" datetime-picker ng-model="promo.time_from" date-format="yyyy-MM-dd HH:mm:ss"/> </div>
When i click on input there's no reaction. I'm looking at the end of page code, but there's no new elements, so this module is not reacting at all. ;/

.css files not being installed

Bower install loads .js file but not .css file. I believe it is because the package.json file is missing "angularjs-datetime-picker.css" in the main field.

{
"name": "angularjs-datetime-picker",
"version": "0.1.20",
"description": "Very Lightweight AngularJS DateTime Picker Without Using jQuery, bootStrap, or moment",
"main": "angularjs-datetime-picker.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},

main only includes the .js file.

Great datetime picker!

Thanks

date resets to current date

when i select a date and time from the date picker, the date is properly filled in the textbox.
but when i again click in the textbox to invoke the date picker, the current date time is set as selected in the date picker.
what could be the problem.
on the website the demo is working properly, but i have downloaded the same code, and it is not working on my machine.

Datepicker is open in end of page in IE

Hello I have a problem with datepicker in Internet Explorer 11. When I click to input, datepicker appears at the bottom of the page. Please tell how to update css for IE. Thanks

option to append the datetime picker component on element other than document body

When I see into the code of the this module it has some line

$document[0].body.appendChild(datetimePickerEl);

I want to open up the datetime pickker on a modal boz which itself appends to the body. So when I use this library, the datetimepicker open up behind the modal box.

Is there any option to customize the appending of datetime picker component on an element other than document body.. I mean can't I give the parent element ref as an input paramter to its api to work like how we can give input paramneter for date format.

Angular Form Properties not affected when selecting a date

As topic states the form properties is not affected when I choose a date (Google Chrome Version 50.0.2661.86 (64-bit))

Here's what I am trying to do:

        <form name="form">
                <input ng-model="model"
                       name="dateTime"
                       datetime-picker
                       date-format="yyyy-MM-dd HH:mm:ss"
                       close-on-select="true" />
            <span ng-show="form.dateTime.$dirty" class="notice">{{ message }}</span>
        </form>

The message only shows if I manually make some input to the field, not when choosing a date from the datetime-picker

No source for css file in bower.json

The css source in bower.json is missing:

"main": "angularjs-datetime-picker.js",

->

"main": [ "angularjs-datetime-picker.js", "angularjs-datetime-picker.css" ],

With this change it's easier to inject the file with browsersync.

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.