title: Angular2: setTimeout only called once
body: <p>I'm implementing functionality in Angular2 that requires the use of <code>setTimeout</code>.</p>
  
  <p>My code:</p>
  
  <pre><code>  public ngAfterViewInit(): void {
      this.authenticate_loop();
    }
  
    private authenticate_loop() {
      setTimeout (() =&gt; {
        console.log("Hello from setTimeout");
      }, 500)
    }
  </code></pre>
  
  <p><code>setTimeout</code> is started by <code>ngAfterViewInit</code> but the loop is only executed once, eg. "Hello fromsetTimeout" is only printed once.</p>
  
  <p><strong>Question:</strong> How can I change the code to make the setTimeout work?</p>