title: Angular 4 | window.scrollTo(); is not working properly
body: <p>Currently, I'm trying to automatically scroll to the top of the HTML page for which I'm using in my Typescript.</p>
  
  <pre><code> window.scrollTo(0 , 0);
  </code></pre>
  
  <p>and while trying to automatically scroll down to bottom of the HTML page</p>
  
  <pre><code> window.scrollTo( 0 , document.body.scrollHeight);
  </code></pre>
  
  <ul>
  <li>I'm trying to scroll top after an HTTP response.</li>
  </ul>
  
  <p><strong>Code</strong></p>
  
  <pre><code> openPDFVievwer(data) {
    this.obj= JSON.parse(data._body);
    document.getElementById('spinner').style.display = 'none';
    window.scrollTo( 0 , 0);
  }
  </code></pre>
  
  <ul>
  <li>when I'm trying to scroll bottom after rendering another component.</li>
  </ul>
  
  <p><strong>Code</strong></p>
  
  <pre><code>searchData(data) {
      this.document = data;
      this.searchResultDiv = true; // where component will be rendered
      window.scrollTo( 0 , document.body.scrollHeight);
    }
  </code></pre>
  
  <p>but, both seem to be not working. </p>
  
  <p>Is there something that I'm doing wrong?</p>