I am currently working on a class that listens for events. When the event is triggered, I need to add the data that accompanies it to an array and then display it. Here's what my class looks like:
export class customClass {
dataArray:Array<string>;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public events: Events) {
events.subscribe('event',
(data) => {
//some random code
this.dataArray.push(data); //this fails
}
)
}
The error message I keep receiving is: TypeError: undefined is not an object (evaluating '_this.communication.push')
I have searched extensively but cannot seem to find a solution to this issue.