Created
July 30, 2016 15:18
-
-
Save JeremyLikness/ef891c512c1cb4d3eea41593b5e82ea4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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