Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i like to show the timepicker as a dropdown (popup) in a input element like the datepicker. Is there any easy way to accomplish this or is a complete new directive necessary ?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

HTML

<div class="container container-fluid" ng-controller="MainCtrl">
       var1={{var1}}
      <form class="form-horizontal" novalidate name="form" ng-submit="submit()">
      <div class="well">
        <div id="date" class="input-append" datetimez ng-model="var1">
          <input data-format="hh:mm:ss"  type="text" id="input1" name="input1"></input>
          <span class="add-on">
            <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
          </span>
        </div>
      </div>
  </form>

  </div>

JS

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.var1 = '12-07-2013';
});


app.directive('datetimez', function() {
    return {
        restrict: 'A',
        require : 'ngModel',
        link: function(scope, element, attrs, ngModelCtrl) {
          element.datetimepicker({           
           language: 'en',
           pickDate: false,          
          }).on('changeDate', function(e) {
            ngModelCtrl.$setViewValue(e.date);
            scope.$apply();
          });
        }
    };
});

Fiddle Demo

share|improve this answer
 
right now plunker is offline (sounds like maintenance) –  Maxim Shoustin Dec 24 '13 at 9:52
 
yeah but i looking for the timepicker as popup –  Abc Dec 24 '13 at 10:02
 
and what is that? its dropdown, see image posted –  Maxim Shoustin Dec 24 '13 at 10:15
 
timepicker not datepicker ;) thanks anyway –  Abc Dec 24 '13 at 10:22
 
Opps, you can create directive and use bootstrap timepicker, see my 2nd edit –  Maxim Shoustin Dec 24 '13 at 10:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.