TypeError: Cannot read properties of undefined

Published

Working in Angular 12 and experiencing an error when I attempt to call a method within another method. Here’s an abstraction of what I’m dealing with (in TypeScript as I am in Angular

doSomething() {
  this.doSomethingElse("Myfirstname", "Mylastname")
}

doSomethingElse(firstname, lastname) {
  return (firstname + lastname)
}

When I run this I get a TypeError: Cannot read properties of undefined. If I include the doSomethingElse function in any of the other functions defined in my class I have no issue and it works as expected. The only other thing of note is that the function where I’m having this issue doSomething() is used as a callback by an external library and that seems to be what is throwing the error whenever I include any reference to something ‘outside’ of doSomething in the doSomething function. Any thoughts would be appreciated

Source: Angular Questions

Published
Categorized as angular, typescript Tagged ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq