title: Angular Directive not setting focus properly on recently disabled input
body: <p>I have an input field that I want to disable when a user presses the 'enter' key. It will then try and fetch a user details. When it has fetched the details or there has been an error, I want to enable the input field again and set the focus on that field.</p>
  
  <p>I am using this directive to set the focus on the input field:</p>
  
  <pre><code>import { Directive, OnChanges, ElementRef, Input } from '@angular/core';
  
  @Directive({
    selector: '[myFocus]'
  })
  export class FocusDirective implements OnChanges {
  
    @Input('myFocus') isFocused: boolean;
    constructor(private hostElement: ElementRef) { }
  
    ngOnChanges() {
      if(this.isFocused) {
          this.hostElement.nativeElement.focus();
      }
    }
  }
  </code></pre>
  
  <p>It is implemented in the html like so:</p>
  
  <pre><code>&lt;input type="text" class="form-control" [(ngModel)]="text"
      [myFocus]="isFocused" [disabled]="disableInput" 
      (keydown)="podcastsKeyDown($event)"&gt;
  </code></pre>
  
  <p>The podcastKeyDown() function looks like this:</p>
  
  <pre><code>podcastsKeyDown(event) {
      if(event.keyCode == 13) {
          this.disableInput = true;
          this.getUser(this.text).subscribe(account =&gt; {
              this.disableInput = false;
              this.isFocused = true;
          });
      }
  }
  </code></pre>
  
  <p>When the user account has successfully returned i set the input field to be enabled, which works correctly. However the focus is not returned to this input. I have tried placing a timeout around re-setting the focus just in case there is some timing issue, however this did not work either. The code looked like this:</p>
  
  <pre><code>setTimeout(() =&gt; {
      this.isPodcastNamesFocused = true;
  }, 100);
  </code></pre>
  
  <p>Any ideas what is happening here and how to fix it?</p>
  
  <p>Thanks in Advance.</p>
  
  <p><strong>EDIT 1:</strong> To be precise - it actually works the first time when using the timeout, but for subsequent user entries it does not...</p>