/* * @ngdoc fbEnterKey * @name fasit.directives.#fbEnterKey * @fbEnterKey * * @description * Directive kopplas till element där en default action skall göras på enter-press */ angular.module('fasit') .directive('fbEnterKey', ['$timeout', function ($timeout: ng.ITimeoutService) { 'use strict'; function link(scope: any, element: fb.IRootElementService, attrs: any) { $(element).keypress(function (e) { if (e.which === 13) { scope.$apply(function () { scope.$eval(attrs.fbEnterKey); }); } }); } function compile(element: fb.IRootElementService, attrs: any) { return link; } return { restrict: 'A', compile: compile } }]);