0

I have a heading and page body, each of which is governed by a separate Controller. Both need the same chunk of data from the API. Everything works, but I can see two concurrent API calls. I'd like to make the $resource or a Service smart enough to return a $promise to both callers, but simply caching and returning the same promise instance only resolves for one of the Controllers.

I've looked around on the web and see plenty of ideas on coordinating multiple requests within a controller. What I'm really looking for is the coordination of a single request across multiple controllers.

Help!

mtutty
  • 815
  • 2
  • 10
  • 22
  • You can register any number of callbacks to the same promise. If you share the promise object accross your different controllers, and register a `.then` callback from each controller, they should be both called. – floribon Mar 06 '15 at 03:12
  • "*returning the same promise instance only resolves for one of the Controllers*" - Huh? That's exactly how it should work. Please post your code so that we can find the mistake – Bergi Mar 06 '15 at 03:15
  • @Bergi That's what I thought, too. It just wasn't clearly stated in any of the docs I could find, so I wanted to make sure. Thanks for the good replies, all, I will try to simplify my test case so I can find the actual problem. At least now I know that my use case is supported. – mtutty Mar 06 '15 at 15:15

0 Answers0