2017-04-10 37 views
0

我是角度初学者。我正试图实现超时。如果用户空闲超过5秒钟,我会显示一个模型。当我成功注销超时时间。该对话框不断出现。我怎样才能解决这个问题。即使在超时后,“IdleStart”功能也会再次启动。 “Angular Js”

enter image description here

这是我的配置。

 IdleProvider.idle(5); 
    IdleProvider.timeout(30); // after 30 seconds idle, time the user out 
    KeepaliveProvider.interval(5*60); 

这是我的事件:

$scope.$on('IdleEnd', function() { 
     Idle.unwatch(); 
     $uibModal.close(); 
    }); 

    $scope.$on('IdleTimeout', function() {  
     Idle.unwatch(); 
     $scope.SignOut(); 
     $uibModal.close(); 
    }); 

    $scope.$on('IdleStart', function() { 
    $scope.warning = $uibModal.open({ 
     templateUrl: 'warning-dialog.html', 
     windowClass: 'modal-danger' 
    }); 
    }); 

修订

代码我的观点:

**<script type="text/ng-template" id="warning-dialog.html"> 
      <div class="modal-header"> 
      <h3>You're Idle. Do Something!!!</h3> 
      </div> 
      <div idle-countdown="countdown" ng-init="countdown=5" class="modal-body"> 
      <uib-progressbar max="5" value="5" animate="false" class="progress-striped active">You'll be logged out in {{countdown}} second(s).</uib-progressbar> 
      </div> 
     </script>** 

在这个div

<div idle-countdown="countdown" ng-init="countdown=5" class="modal-body"> 

如果我删除idle-countdown =“倒计时”然后模型不会再出现,并注销我,但我侧杆不断显示。我无法弄清楚。

边栏包含菜单和下拉菜单,但登录了这些菜单disapperas但这种平淡侧栏不断显示只是通过删除“中止倒计时”

enter image description here

+0

你能给我们一个小提琴或这个... – Sankar

+0

它不可能导致它的很多代码。 –

回答

0

也许你需要之前调用Idle.unwatch();signing out

+0

我试过了,但没有奏效。 –

+0

你在哪里调用'$ uibModal.close()'?您需要关闭模式才能消失。 –

+0

$ uibModal.close();我也在空闲结束和空闲超时后添加了这个。没有工作。 –

0
$scope.$on('IdleEnd', function() {  
    $timeout(function() { 
         $scope.$apply(function() { 
            Idle.unwatch(); 
             $uibModal.close(); 
         }); 
        }, 100); 
     }); 

试试这个。

+0

Nop它没有工作。相反,模型不会在注销后关闭。 –

+0

请在[email protected]分享您的演示代码 –

相关问题