restangular icon indicating copy to clipboard operation
restangular copied to clipboard

Restangular promise chain when used in a service breaks?

Open pankajtandon opened this issue 13 years ago • 2 comments

Hi, I've (re)-created a plunker:

http://plnkr.co/edit/7Ir9K3

For some reason, the object returned by a restangular promise when called via a service breaks. But the same works when called within a controller. There are three use cases in script.js that explain the three scenarios.

Can you please explain this behavior?

Thanks!

pankajtandon avatar Oct 02 '13 01:10 pankajtandon

Hey,

That's because you were calling the then on the promise, (which returns a new promise), but then returning in the service the old promise.

http://plnkr.co/edit/uQFJ7T?p=preview this is the same example but working!

Check it out!

mgonto avatar Oct 03 '13 19:10 mgonto

That was because of not fully getting my head wrapped around promises! Thanks for helping.

pankajtandon avatar Oct 03 '13 20:10 pankajtandon