I'm having troubles with scrolling from ts, I tried different methods that worked for other people but they all failed
this is how I declare the div
<div #chat id="chat" class="card-body msg_card_body">
...
</div>
this is the simple CSS
.msg_card_body {
overflow-y: auto;
}
and this is how I tried to scroll it
ngAfterViewInit(): void {
this.scrollDown();
}
scrollDown(){
var container = this.el.nativeElement.querySelector("#chat");
console.log(container.scrollTop)
console.log(container.scrollHeight)
container.scrollTop = container.scrollHeight;
console.log(container.scrollTop)
}
from the various console logs I noted that scrollTop is 0, scrollHeight is over 500, and after I assign scrollHeight to scrollTop scrollTop remains 0
I'm genuinely confused
ngAfterViewCheckedrather thanngAfterViewInit?