Listen on keydown in app.run() in order to avoid $digest repetitions

This commit is contained in:
Guillaume Wuip 2014-12-16 10:04:18 +01:00
parent 830ffa134e
commit a23fb326d6
2 changed files with 7 additions and 5 deletions

View file

@ -17,7 +17,7 @@
</head>
<body ng-keydown="onKeyDown">
<body>
<header class="header">

View file

@ -98,8 +98,9 @@
'$location',
'$q',
'$window',
'$document',
'ScribeAPI',
function ($rootScope, $location, $q, $window, ScribeAPI) {
function ($rootScope, $location, $q, $window, $document, ScribeAPI) {
/**
* getAllLogsFiles
@ -222,11 +223,12 @@
}
};
$rootScope.onKeyDown = function ($event) {
$document.bind('keydown', function ($event) {
if ($event.keyCode == 27) {
$rootScope.sidebar = false
$rootScope.sidebar = false;
$rootScope.$digest()
}
}
});
}
]);