Code coverage report for js/directives/todoEscape.js

Statements: 50% (3 / 6)      Branches: 0% (0 / 2)      Functions: 33.33% (1 / 3)      Lines: 50% (3 / 6)      Ignored: none     

All files » js/directives/ » todoEscape.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21            2       2   2                
/*global angular */
 
/**
 * Directive that executes an expression when the element it is applied to gets
 * an `escape` keydown event.
 */
angular.module('todomvc')
	.directive('todoEscape', function () {
		'use strict';
 
		var ESCAPE_KEY = 27;
 
		return function (scope, elem, attrs) {
			elem.bind('keydown', function (event) {
				if (event.keyCode === ESCAPE_KEY) {
					scope.$apply(attrs.todoEscape);
				}
			});
		};
	});