我想在控制器中设置一个计时器,如果用户没有点击任何按钮或输入任何字段1分钟,页面就会进入登录页面。
任何想法如何做到这一点?
答案 0 :(得分:3)
答案 1 :(得分:2)
您可以使用以下内容:
app.run(function($rootScope) {
var lastDigestRun = new Date();
$rootScope.$watch(function detectIdle() {
var now = new Date();
if (now - lastDigestRun > 1*60*60) {
// login here, etc
}
lastDigestRun = now;
});
});