Created
October 24, 2013 10:22
-
-
Save dbajpeyi/7134692 to your computer and use it in GitHub Desktop.
AngularJS timepicker directive
This file contains 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
appDirective.directive('timePicker',function(){ | |
return { | |
restrict : 'E', | |
require: ['ngModel'], | |
scope :{ | |
ngModel: '=' | |
}, | |
replace: true, | |
template: | |
'<div class="input-group bootstrap-timepicker">' + | |
'<input type="text" class="form-control" ngModel>' + | |
'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i>' + | |
'</div>', | |
link: function(scope, element, attrs){ | |
var input = element.find('input'); | |
input.timepicker('showWidget'); | |
element.bind('blur keyup change', function(){ | |
scope.ngModel = input.val() | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment