Written in typescript, I have this:
export class EventDiscussionPage {
messages: any = []
private _channel: any;
initChat() {
this._channel.on('messageAdded', function(message) {
this.messages.push(message);
}
}
}
When a message is added, I get cannot read property 'push' of undefined
. I guess I'm having a scope issue - how do I add the message to this.messages
?