Reputation: 453
I am working in angularjs and ionic project. Here I need to change the state and after 10 seconds, I need to come back to the previous state.
Below is my code:
if (response.data[i].id == opport.id && response.data[i].status == 2 && response.data[i].contractor_fse_counterprice == "accept") {
$state.go("tab.chats");
/*setTimeout(function () {
$state.go("tab.chats")
}, 10000);*/
}
How can I implement the time interval for execution of the function of changing state and returning back after 10 seconds in angularjs?
Upvotes: 0
Views: 83
Reputation: 349
AngularJs has a $timeout
function.
Simply inject $timeout in your controller and then use it in the format below;
$timeout(function() {
// what to call
$state.go("tab.chats")
}, 10000) // 10000 = 10 seconds
Upvotes: 1