[Vuejs]-Empty textfield after button click nativescript vue

0👍

Move the newMessage within .then(). You can try debug by adding console.log after newMessage was cleared and see whats the output.

onSendMessage() {
  if (this.newMessage != "") {
    let currentDate = Date()
    firebase
      .push("/messages/" + this.chatId, {
        message: this.newMessage,
        sender: this.getUserID,
        timestamp: currentDate,
      })
      .then(function (result) {
        console.log("created key: " + result.key); 

        this.newMessage = ""

      });
  }
},

Leave a comment