Javascript AngularJS:跟踪在web应用程序中花费的时间,然后在特定时间触发事件

Javascript AngularJS:跟踪在web应用程序中花费的时间,然后在特定时间触发事件,javascript,angularjs,asp.net-mvc,Javascript,Angularjs,Asp.net Mvc,我想跟踪用户使用网站的时间,然后当用户在网站上停留30秒时,我需要引发一个事件。你知道怎么做吗?为什么不使用Angular内置的$timeout $timeout(function raiseEvent(){ //do something here }, 30000) 为什么不使用Angular的内置$timeout $timeout(function raiseEvent(){ //do something here }, 30000) 密码在哪里 下面是一个没有角度代码的示例

我想跟踪用户使用网站的时间,然后当用户在网站上停留30秒时,我需要引发一个事件。你知道怎么做吗?

为什么不使用Angular内置的
$timeout

$timeout(function raiseEvent(){
   //do something here
}, 30000)

为什么不使用Angular的内置
$timeout

$timeout(function raiseEvent(){
   //do something here
}, 30000)
密码在哪里

下面是一个没有角度代码的示例,但可以随意使用$timeout并将其放入应用程序中。如果您希望对其进行调整,请运行

// 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 );
});
密码在哪里

下面是一个没有角度代码的示例,但可以随意使用$timeout并将其放入应用程序中。如果您希望对其进行调整,请运行

// 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 );
});

到目前为止你写了什么?到目前为止你写了什么?