Scroll To bottom does not work with Observable?


I’m building a chat app with Ionic angular firebase and when I send a new message i call the scrollToBottom() function. The problem is that the chat window goes to top (very quick less than 1sec) before going to bottom. So it feels like the application is bugged because when I send a message it goes straight top very quick and then after goes to bottom.

Here is my code:


getChatMessages() {
return this.afs
  .collection("messages", (ref) => ref.orderBy("createdAt", "asc"))
  .valueChanges({ idField: "id" }) as Observable<Message[]>;}


    <ion-buttons slot="start">

    <ion-item *ngFor="let message of messages | async">
      <ion-avatar slot="start">
        <img src="{{message.img_url}}">
        <h2>{{ message.from_name }} {{ message.createdAt?.toMillis() | date:'short' }}</h2>
        <p>{{ message.msg }}</p>
<ion-toolbar color="light">
  <ion-row class="ion-align-items-center">
    <ion-col size="10">
      <ion-textarea autoGrow="true" class="message-input" rows="1" maxLength="500" [(ngModel)]="newMsg"
    <ion-col size="2">
      <ion-button expand="block" fill="clear" color="primary" [disabled]="newMsg === ''" class="msg-btn"
        <ion-icon name="send" slot="icon-only"></ion-icon>


export class TchatPage implements OnInit, AfterViewChecked {
  @ViewChild(IonContent) content: IonContent;

  messages: Observable<any[]>;
  newMsg = "";

  constructor(private tchatService: TchatService) {}

  ngOnInit() {
    this.messages = this.tchatService.getChatMessages();

  ngAfterViewChecked() {

  sendMessage() {
    this.tchatService.addChatMessage(this.newMsg).then(() => {
      this.newMsg = "";

  handleSubmit(event) {
    if (event.keyCode === 13) {