Skip to content

Instantly share code, notes, and snippets.

@ishanray
Created March 8, 2014 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishanray/9427896 to your computer and use it in GitHub Desktop.
Save ishanray/9427896 to your computer and use it in GitHub Desktop.
app.directive('timePicker', function(){
return {
restrict: 'A',
replace: true,
scope: {
time: '='
},
templateUrl: 'js/partials/time-picker.html',
link: function(scope, el, attr){
var hideDropDown = function() {
scope.showTimeDropdown = false;
scope.$apply();
};
el.bind('click', function(e){
if (e.target.nodeName === 'INPUT'){
scope.showTimeDropdown = true;
scope.$apply();
} else if (e.target.nodeName === 'LI'){
var time = angular.element(e.target).html();
scope.time = time;
hideDropDown();
}
});
el.bind('mouseleave', function(){
hideDropDown();
});
}
}
}); //end of timepicker directive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment