domingo, 3 de abril de 2016

Ionic - Timeout

Hi, I will show here how to use the $timeout with Ionic:

Create a variable:
var myTimeout;

Start the timeout:
myTimeout = $timeout(timeIsOver, 10000);
The first parameter is a the function that will be executed after the time that you will set in the second parameter. In this case, 10000 milliseconds (10 seconds)


And do something when the time is over:
function timeIsOver(){
    console.log('timeIsOver');
}

And if, before the time ends, you want to cancel the timeout for not executing the timeIsOver function, just do that:
timeout.cancel(myTimeout);

Thats it :)

Best regards,
Adriano Schmidt

Nenhum comentário:

Postar um comentário