Functional directives TS
This commit is contained in:
18
app/assets/javascripts/directives/functional/snEnter.ts
Normal file
18
app/assets/javascripts/directives/functional/snEnter.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/* @ngInject */
|
||||
export function snEnter() {
|
||||
return function (
|
||||
scope: ng.IScope,
|
||||
element: JQLite,
|
||||
attrs: any
|
||||
) {
|
||||
element.bind('keydown keypress', function (event) {
|
||||
if (event.which === 13) {
|
||||
scope.$apply(function () {
|
||||
scope.$eval(attrs.snEnter, { event: event });
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user