Skip to content

Instantly share code, notes, and snippets.

@riwsky
Created October 5, 2013 20:55
Show Gist options
  • Save riwsky/6845895 to your computer and use it in GitHub Desktop.
Save riwsky/6845895 to your computer and use it in GitHub Desktop.
a simple angularjs directive module for Keith Wood's jquery time entry (http://keith-wood.name/timeEntry.html)
angular.module('jqTimeEntry', [])
.directive('jqTimeEntry', function () {
return {
scope: {timeModel: "="},
link: function (scope, element, attrs) {
$(element).timeEntry({show24Hours: true, ampmNames: ['a', 'p'],
ampmPrefix: ' ', useMouseWheel: true,
showSeconds: false, timeSteps: [1, 1, 1],
spinnerImage: ''
}).change(function () {
scope.timeModel = $(element).timeEntry('getTime');
})
scope.$watch('timeModel', function (newValue, oldValue) {
$(element).timeEntry('setTime', newValue);
})
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment