2

Why am I getting 'cannot call method 'then' of undefined':

http://plnkr.co/edit/yWS6hRjmZZeZMJyVA0zy?p=preview

Can you not resolve a promise inside the .then of another promise?

The code works fine if you take out the call to doSomething(), and it gets the suburbs, but as soon as you add the call to doSomething() it fails with that .then undefined error.

The call to doSomething also works if it's outside of the .then for the requests to get the suburbs, so that's why I'm lead to believe it's something to do with it being embedded.

Thank you

1
  • 3
    Please edit to post the relevant portions of your code here. Questions should stand on their own, without dependence on external sites for their main content. Posting the majority of the content off-site means that your question lacks meaning if that off-site location is unavailable for some reason, and it's not searchable by future readers here. (It also requires people to leave this site in order to determine what you're asking, and then return here to post an answer.) Commented Jul 29, 2013 at 2:18

1 Answer 1

9

I saw your plunk and there is a minor error. I am giving the corrected plunker. http://plnkr.co/edit/vRuA5Vy8sT6BhzsaYTkl?p=preview

doSomething : function() {
  //your method isn't returning anything
  return $http().then();
}
Sign up to request clarification or add additional context in comments.

2 Comments

If your method does not return the promise generated by the then function, how can you controller code interact with the promise
Yeah actually I was mistaken, the other service functions do return the promise. Looks like I missed the return statement.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.