Chaining restangular from a service
Hi, I'd like to call a service from a controller. In the service, I want to make a Restangular call which returns a promise, massage the returned data in the success callback, and then pass back the promise to the controller where I would assign the hopefully massaged data to a variable on the $scope.
I wrote a plunkr here http://plnkr.co/edit/7Ir9K3?p=preview
to do this, but it does not work. Even tho Restangular returns the correct data, and I can massage it in the service, what I get back in the controller is NOT the massaged object but a Restangularized object.
Is this the right way to chain promises in restangular?
Thanks a lot for your help and for a great project!
Hey,
I've seen the plunkr but I don't completely understand your point. I do see that when you're using the service, the firstName is correctly changed when using it in the controller, so you're setting the massaged data in the controller. What's your problem here?
Thanks!
Hi, I'm sorry, I wrote that plunker in a hurry and did not annotate it correctly. I've fixed it now: http://plnkr.co/edit/7Ir9K3?p=preview And after I did that, I realized I was wasting your time :) Sorry about that!
Haha no problem :)
Glad to help!