grbsk / ng-idle

Responding to idle users in AngularJS applications.
http://hackedbychinese.github.io/ng-idle
MIT License
564 stars 195 forks source link

only timeout function executes #190

Open lifesucks0831 opened 7 years ago

lifesucks0831 commented 7 years ago

i have written like: `app.controller('EventsCtrl',

function ($scope, Idle) {

    $scope.events = [];

    Idle.setTimeout(5);

    Idle.setIdle(5);

    $scope.$on('IdleStart', function () {
        addEvent({ event: 'IdleStart', date: new Date() });
    });

    $scope.$on('IdleEnd', function () {
        addEvent({ event: 'IdleEnd', date: new Date() });
    });

    $scope.$on('IdleWarn', function (e, countdown) {
        addEvent({ event: 'IdleWarn', date: new Date(), countdown: countdown });
    });

    $scope.$on('IdleTimeout', function () {
        addEvent({ event: 'IdleTimeout', date: new Date() });
    });

    $scope.$on('Keepalive', function () {
        addEvent({ event: 'Keepalive', date: new Date() });
    });

    function addEvent(evt) {
        $scope.$evalAsync(function () {
            $scope.events.push(evt);
        })
    }

    $scope.reset = function () {
        Idle.watch();
    }
})
  .config(function (IdleProvider, KeepaliveProvider) {
      KeepaliveProvider.interval(10);
      IdleProvider.windowInterrupt('focus');
  })
  .run(function ($rootScope, Idle, $log, Keepalive) {
      Idle.watch();

      $log.debug('app started.');
  });`

but never get catch keepalive on idleend event whats wrong in this?