Reputation: 815
I want to track the time the user use the website and then I need to raise an event when the user have been on the site for 30 seconds. Any idea on how to do this?
Upvotes: 0
Views: 540
Reputation: 540
where's the code? ..
heres an example without angular code, but feel free to use a $timeout and drop it inside of your app.run if you want it algularized.
// This event starts watching when document loads
// Any special event can work to trigger this instead
$(document).ready(function(){
var countdown = 30000;
// 30 Second Event
function thirty_second_event() {
console.log("it's been " + (countdown/1000) + " seconds");
}
// Start the timer
setTimeout( thirty_second_event, countdown );
});
Upvotes: 1
Reputation: 12129
Why not use Angular's built in $timeout
$timeout(function raiseEvent(){
//do something here
}, 30000)
Upvotes: 2