Angular 4 setTimeout does not wait : <p>I am creating an angular 4 app with typescript.</p>

<p>I'm having a function that needs to be executed every 10 seconds untill a specified stopcondition. I created a loop with some testcode using setTimeout to see if it would work. </p>

<p>My Testcode:</p>

<pre><code>public run() {
    let i = 0;
    while (i &lt; 4) {
        setTimeout(this.timer,3000);
        i++;
    }
}

public timer(){
    console.log("done")
}
</code></pre>

<p>However this seems to wait for 3 seconds, or browser is just slow...
and then it prints 4 times done. So the code isn't working. Am I doing this wrong or are there other possibilities to do this kind of things?</p>
