User Idle Example
HTML
<div ng-app>
<div ng-controller="IdleWatch">
<input type="text"/>
<input type="text"/>
<span ng-show="!isIdle()">User not idle</span>
<span ng-show="isIdle()">User idle</span>
</div>
</div>
JavaScript
function IdleWatch ($scope, $interval, $document) {
var int = null;
var callbacks = [];
var idleTime = 0;
$scope.isIdle = function() {
return (idleTime > 0);
};
angular.element($document).bind('mousemove', function(e) {
idleTime = 0;
$interval.cancel(int);
startInterval();
$scope.$apply();
});
function startInterval() {
int = $interval(function() {
idleTime += 3000;
}, 3000);
}
startInterval();
}