Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 4
    Cart controller will update once when getProducts() is called? Or every time new product is added? Commented Nov 24, 2013 at 22:02
  • 1
    If you want it to automatically update, you can add the broadcast from Maxim Shoustin's answer and call getProducts() within the $on function to update the CartCtrl's scope. Commented Nov 24, 2013 at 22:21
  • 2
    @krillgar You are completely correct, that was overlooked initially. I've edited the answer to reflect a working solution. Commented Jun 6, 2014 at 19:27
  • 1
    @DeveshM Yes, do as you suggest. You may want to consider extending the methods so they are not just holding data in memory and to be more persistent (save to server via $http call, for example). Commented Aug 24, 2015 at 0:26
  • 1
    What happens if I have 2 productControllers and 2 carts for example? Both will have the element added? How do you solve that in this case? Commented Feb 25, 2016 at 15:28