1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| /**
| * Created by wisestone on 2017-12-21.
| */
| 'use strict';
|
| define(['app'],
| function (app) {
| app.directive('ngEnter', [
| function () {
| return {
| restrict: 'A',
| link: function (scope, element, attrs) {
| element.unbind("keydown keypress");
|
| element.bind("keydown keypress", function (event) {
| switch (event.target.nodeName) {
| case "TEXTAREA" :
| case "DIV" :
| break;
| default :
| if (event.which === 13) {
| scope.$apply(function () {
| scope.$eval(attrs.ngEnter);
| });
| event.preventDefault();
| }
| }
| });
| }
| };
| }])
| });
|
|