Skip to content

Instantly share code, notes, and snippets.

@JeremyLikness
Created July 30, 2016 15:18
Show Gist options
  • Select an option

  • Save JeremyLikness/ef891c512c1cb4d3eea41593b5e82ea4 to your computer and use it in GitHub Desktop.

Select an option

Save JeremyLikness/ef891c512c1cb4d3eea41593b5e82ea4 to your computer and use it in GitHub Desktop.
import { Component, Input, ElementRef, OnChanges, ViewChild } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'console',
templateUrl: 'console.component.html',
styleUrls: ['console.component.css']
})
export class ConsoleComponent implements OnChanges {
private div: HTMLDivElement;
@ViewChild('consoleDiv')
public set consoleDiv(elem: ElementRef) {
this.div = elem.nativeElement;
}
@Input('list')
public list: string[];
constructor() { }
ngOnChanges(): void {
if (this.div) {
setTimeout(() => this.div.scrollTop = this.div.scrollHeight, 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment