简体   繁体   中英

AngularJS: how can I call a function after certain time interval?

My Scenario is:

I want to call logout function after let say 30 mins automatically in my app. Is this possible to acheive this? And more over i want to know the time of user's last interactivity with my application. Can anybody help me regarding this??

Use below for any function that requires time out. But I will not suggest this for Logout. Better you can use browser session to logout after 30 min.

$timeout(function() {
   // your code
}, 3000); // 3 seconds

use setTimeout() pure javascript function that can be invoked after a time of interval

 setTimeout(function(){
    logout();
},5000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM