Question: Need to scroll dialog to top so that alert comes into view after form submission. 
Tried this but doesn't seem to work on dialogs.

```
window.scrollTo(0,0);

```

Answer: 
```js
document.getElementById('formsubmit').onclick=function(){
  document.getElementById('form').scrollTop = 0;
  return false;
}
```

```css
input {
  display:block;
}

.form {
  height:100px;
  overflow-y:auto;
}
```

```html
<div>
  <h1>form</h1>
  <div class="form" id="form">
    <input type="text">
    <input type="text">
    <input type="text">
    <input type="text">
    <input type="text">
    <input type="text">
    <input type="text">

    <input type="submit" id="formsubmit">
  </div>
</div>
```
Although this question has been marked as the answer, this isn't the angular-y way of scrolling to the top. A better way of doing this is by doing: 

```js
@ViewChild('scrollContainer') private myScrollContainer: ElementRef;

constructor(private _renderer: Renderer2) {}
onFormSubmit() {
    this._renderer.setProperty(this.scrollContainer.nativeElement, 'scrollTop', this.scrollContainer.nativeElement.scrollHeight);
}
```

```css
input {
  display:block;
}

.form {
  height:100px;
  overflow:auto;
}
```

```html
<div>
    <h1>form</h1>
    <div #scrollContainer class="form">
        <input type="text">
        <input type="text">
        <input type="text">
        <input type="text">
        <input type="text">
        <input type="text">
        <input type="text">
        <input type="submit" (click)="onFormSubmit()">
    </div>
</div>
```

A good rule of thumb is that if you see ```document`` then you're not doing something the angular way, but the vanilla js way.

A big mistake that people commonly make is that they use the ElementRef to setValues, properties, css. Per the angular docs, ElementRef should be used as a last resort. You can read more about that here: <https://angular.io/api/core/ElementRef>