2017-04-10 107 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]分享您的演示代碼 –

相關問題