Morris
Morris

Reputation: 601

Typescript error: Cannot read property X of undefined

i created an instance of class Meetings:

export var meeting: Meetings; //create a meeting instance of Meeting class present into meeting.ts

and when i call a function called "meetForMe()" on Meetings class:

var myMeeting = meeting.meetForMe(email);

i receive this error:

Cannot read property 'meetForMe' of undefined

I have declared class Meetings in this way:

export class Meetings{....}

Upvotes: 3

Views: 753

Answers (2)

You haven't initialized the meeting variable yet. Try export var meeting: Meetings = new Meetings(); instead

Upvotes: 1

TSV
TSV

Reputation: 7641

Object shoud be created before it can be used:

export var meeting = new Meetings();

In your code you just declare a variable of "Meetings" type.

Upvotes: 2

Related Questions