title: How to get an element with condition of modal dialog in Angular 2?
body: <p>I'm using ng2-modal to create a modal dialog in Angular 2. I am unable to get an element that has a condition on it (#myModalScrollPanel). </p>
  
  <p>Template (<strong>modal.html</strong>):</p>
  
  <pre><code>&lt;modal  #myModal title="{{title}}"
      cancelButtonLabel="Close"
      submitButtonLabel="Ok"
      modalClass="@modal-md"
      [hideCloseButton]="false"
      [closeOnEscape]="false"
      [closeOnOutsideClick]="false"
  &gt;
  &lt;modal-header&gt;&lt;/modal-header&gt;
    &lt;modal-content&gt;
      &lt;div class="row"&gt;
        &lt;div *ngIf="logOutput" class="col-md-12"&gt;
          &lt;div id="myModalScrollPanel" #myModalScrollPanel class="panel-body fixed-panel"&gt;
            &lt;p *ngFor="let entry of logOutput.entries"&gt;{{entry.log}}&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/modal-content&gt;
    &lt;modal-footer&gt;&lt;/modal-footer&gt;
  &lt;/modal&gt;
  </code></pre>
  
  <p>In my component I get View Children (<strong>modal.component.ts</strong>):</p>
  
  <pre><code>@ViewChild('myModal') myModalModal;
  @ViewChild('myModalScrollPanel') myModalScrollPanel;
  </code></pre>
  
  <p>After a users clicks a button, I show the modal and get log text from the server, I call updateScrollPosition() once I have updated logOutput (<strong>modal.component.ts</strong>):</p>
  
  <pre><code>updateScrollPosition() {
    console.log("modal:");
    console.log(this.myModalModal);
    console.log("log scroll panel:");
    console.log(this.myModalScrollPanel);
  
    if(this.myModalScrollPanel){
      console.log("Scrolling the panel down");
      this.myModalScrollPanel.nativeElement.scrollTop = this.myModalScrollPanel.nativeElement.scrollHeight;
    } else {
      console.log("No log scroll panel.");
    }
  }
  </code></pre>
  
  <p>The console shows a valid object for "modal" and 'undefined' for log scroll panel. 
  I also tried calling that method from ngAfterViewInit(), but it only gets called when the parent component is loaded, and not the actual modal being shown, so the if statement results in false and element doesn't exist yet. If I remove/move the if statement, so that the element exists I can then access that object, but the changes I make do not take any effect, although that might be a whole different issue (most likely to do with change detection). </p>
  
  <p>In the end, I just want to scroll to the bottom of the panel. Something like this (which works in the browser console):</p>
  
  <pre><code>var scrollPanel = document.getElementById('myModalScrollPanel');    
  scrollPanel.scrollTop = scrollPanel.scrollHeight;
  </code></pre>
  
  <p>Thanks in advance!</p>