import {..., AfterViewChecked, ElementRef, ViewChild, OnInit} from 'angular2/core'
@Component({
...
})
export class ChannelComponent implements OnInit, AfterViewChecked {
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
ngOnInit() {
this.scrollToBottom();
}
ngAfterViewChecked() {
this.scrollToBottom();
}
scrollToBottom(): void {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
}
}
<div #myscroll> apply id to overflow div </div>
@ViewChild('myscrool') myscrool: ElementRef;
ngAfterViewChecked(){
this.myscrool.nativeElement.scrollTop = this.myscrool.nativeElement.scrollHeight;
}