angular.module('appWrapperDemo') .controller('appWrapperDemoController', [ '$scope', '$rootScope', '$timeout', function($scope, $rootScope, $timeout) { $scope.usarTeclado = false; $scope.mostrarTeclado = false; $rootScope.$on('focus', function(event) { if(!$scope.usarTeclado) { return; } $scope.mostrarTeclado = true; $timeout.cancel($scope.timeout); if(!$scope.$$phase) { $scope.$apply(); } }); $rootScope.$on('blur', function(event) { $scope.timeout = $timeout(function(){ $scope.mostrarTeclado = false; if(!$scope.$$phase) { $scope.$apply(); } }, 150); }); } ]);