Files
stf-DeviceFarmer/res/app/components/stf/common-ui/ng-enter/ng-enter-directive.js
Gunther Brunner 553b89f764 - Add ngEnter.
2014-03-31 19:14:02 +09:00

12 lines
331 B
JavaScript

module.exports = function ngEnterDirective() {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.ngEnter, {'event': event})
})
event.preventDefault()
}
})
}
}