Created
August 10, 2015 21:02
-
-
Save jkresner/7a81a1882452966f16ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="dropdown"> | |
<a id="{{id}}" class="dropdown-toggle {{id}}" | |
role="button" data-toggle="dropdown" data-target="#" href="#"> | |
<div class="input-group"> | |
<input type="text" class="form-control" value="{{datetime.format(dateFormat)}}"> | |
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span> | |
</div> | |
</a> | |
<ul ng-if="minView" class="dropdown-menu" role="menu" aria-labelledby="dLabel"> | |
<datetimepicker data-ng-model="datetime" | |
data-datetimepicker-config="{ minView:'{{minView}}', startView:'{{startView}}', minuteStep: {{minuteStep}} }" | |
data-on-set-time="onSetTime(newDate, oldDate)"></datetimepicker> | |
</ul> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('datetimeInput', function() { | |
return { | |
restrict: 'EA', | |
template: require('./datetimepicker.html'), | |
scope: { | |
datetime: '=datetime', | |
setCallback: '=setCallback' | |
}, | |
link: function(scope, element, attrs) { | |
scope.id = attrs.id | |
scope.minView = attrs.minView || 'day' | |
scope.startView = attrs.startView || 'day' | |
scope.minuteStep = attrs.minuteStep || 30 | |
scope.dateFormat = attrs.dateFormat || 'YYYY MMM DD' | |
}, | |
controller: function($scope, $element, $attrs) { | |
$scope.onSetTime = (newDate, oldDate) => { | |
if ($scope.setTimeCallback) | |
scope.setTimeCallback(newDate, oldDate) | |
$element.find('.dropdown').removeClass('open') | |
$scope.datetime = moment(newDate) | |
} | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment