Your system information:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v6.9.2
Xcode version: Not installed
Upon pushing to a Conversation-view, an error occurs. The client connects to a message server using socketIO to receive new messages and automatically scroll down to display the newest message. Initially, everything works fine, but when navigating back and returning to the page, an error is encountered.
Error Message:
Cannot read property scrollToBottom of null
connect() {
this.socket.on("connect", () => {
console.log("connected");
console.log("Listening on: "+"message_"+this.secretid);
this.socket.emit('message', { type: "token", token: this.secretid });
this.socket.on("message_"+this.secretid, (msg) => {
let msg_data = JSON.parse(msg);
msg_data.payload.writer_id = msg_data.payload.user;
console.log(msg_data);
this.chat.push(msg_data.payload);
this.content.scrollToBottom(); <<--Error
});
});
}
Connect is called in ionViewDidLoad() {}
, so this.content
should be initialized.
I'm using Ionic 2.
Note: This error only occurs in Ionic Lab.