Skip to content

Instantly share code, notes, and snippets.

@snapwich
Created June 23, 2015 13:17

Revisions

  1. snapwich created this gist Jun 23, 2015.
    23 changes: 23 additions & 0 deletions angular a11y
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // keyboard and accessibility directive
    .directive("ngClick", function() {
    var KEY_ENTER = 13,
    KEY_SPACE = 32;
    return {
    restrict: "A",
    link: function(scope, elem, attrs) {
    elem.css({
    cursor: "pointer"
    });
    elem.on("keyup", function(e) {
    switch(e.which) {
    case KEY_ENTER:
    case KEY_SPACE:
    scope.$apply(function() {
    scope.$eval(attrs.ngClick);
    });
    break;
    }
    })
    }
    };
    });