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?
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
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.