Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  94] [ 6]  / answers: 1 / hits: 12463  / 11 Years ago, tue, december 24, 2013, 12:00:00

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 ?


More From » angularjs

 Answers
1

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


[#49254] Monday, December 23, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ericmaximilianz

Total Points: 252
Total Questions: 118
Total Answers: 87

Location: Virgin Islands (U.S.)
Member since Tue, Jul 7, 2020
4 Years ago
;