I have a jquery key event listener which looks for the Ctrl+C event. My problem is commented below.
jQuery(window).on('keydown', function(e){
if(e.ctrlKey && e.which == '67')
{
// console.log('pressed'); This works
// $scope.closeShareBar(); This works
$scope.showNotif('The URL has been copied to your clipboard', null, true); // This DOES NOT work
}
});
$scope.showNotif('The URL has been copied to your clipboard', null, true); // This works
Why is it not working?
$scope.showNotif()
is a function I have written to show notifications.
edit
I hope i have made it clear that $scope.closeShareBar();
works without $apply()
. Why does only this work then? Isn't this angular too?
edit 2
$scope.showNotif = function(text, status, closeEnabled, quick){
$scope.notif_text = text;
$scope.notif = status || 'show';
if (closeEnabled == true)
{
$timeout.cancel($scope.timer);
$scope.timer = $timeout(function(){
$scope.notif = '';
}, 3000);
}
if (quick == true)
{
$scope.notif = '';
}
}
$scope.closeShareBar = function(){
// $scope.shareLink = 'http://localhost:3000/single-signal/'+id;
angular.element(document.querySelectorAll('.signal_wrapper .signal_data')).removeClass('share_overlay');
angular.element(document.querySelectorAll('.signal_wrapper .sb_status .share')).removeClass('hide');
angular.element(document.querySelectorAll('.signal_wrapper .sb_status .close')).addClass('hide');
}