-2

I want to execute function in angular on a specific time interval and how can we stop that too. Please give me solution for that.

Random
  • 3,158
  • 1
  • 15
  • 25

1 Answers1

2

Your question seems to be about JavaScript in general, not specifically Angular. You could use setInterval and clearInterval to execute a function on a fixed interval:

// Will print each second
let interval = setInterval(() => console.log("I am a text"), 1000)

// Stops the interval
clearInterval(interval)

Documentation: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval

Numbnut
  • 106
  • 1
  • 5