最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS angular-ui bootstrap timepicker as dropdown - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question asked Dec 24, 2013 at 9:43 MR.ABCMR.ABC 4,86213 gold badges47 silver badges89 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

发布评论

评论列表(0)

  1. 暂无评论