Code coverage report for js/directives/todoFocus.js

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

All files » js/directives/ » todoFocus.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21            2       2                    
/*global angular */
 
/**
 * Directive that places focus on the element it is applied to when the
 * expression it binds to evaluates to true
 */
angular.module('todomvc')
	.directive('todoFocus', function todoFocus($timeout) {
		'use strict';
 
		return function (scope, elem, attrs) {
			scope.$watch(attrs.todoFocus, function (newVal) {
				if (newVal) {
					$timeout(function () {
						elem[0].focus();
					}, 0, false);
				}
			});
		};
	});