【问题标题】:"IdleStart" function starts again even after timeout. "Angular Js"“IdleStart”功能即使在超时后也会重新启动。 “角J”
【发布时间】:2017-04-10 12:58:22
【问题描述】:

我是角度的初学者。我正在尝试实现超时。如果用户空闲超过 5 秒,我会显示一个模型。当我在 超时 上成功注销时。此对话框不断出现。我该如何解决这个问题。

这是我的配置。

     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="countdown",则模型不会再次出现并将我注销,但我的侧边栏仍然显示。我想不通。

侧边栏包含菜单和下拉菜单,但在登录后这些菜单消失,但这个简单的侧边栏通过删除“空闲倒计时”继续显示

【问题讨论】:

  • 你能给我们一个小提琴或 plunker 这个...
  • 这不可能,因为它有很多代码。

标签: angularjs timeout


【解决方案1】:

您可能需要在signing out 之前调用Idle.unwatch();

【讨论】:

  • 你在哪里调用$uibModal.close()?您需要关闭模式以使其消失。
  • $uibModal.close();我也在空闲结束和空闲超时后添加了这个。没用。
  • 我有一个观察结果,所以我更新了我的问题,你可以看看吗?
【解决方案2】:
   $scope.$on('IdleEnd', function() {     
     $timeout(function() {
                        $scope.$apply(function() {
                                     Idle.unwatch();
                                      $uibModal.close();
                        });
                    }, 100);
       });

试试这个。

【讨论】:

  • 不,它不起作用。而不是模型在注销后不会关闭。
  • 请在 parag7ghadge@gmail.com 分享您的演示代码
猜你喜欢
  • 1970-01-01
  • 2016-06-21
  • 2019-06-16
  • 2016-02-10
  • 2021-06-23
  • 1970-01-01
  • 2021-11-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多