I've been reading that Services are great for sharing data. But I am having a hard time making all data be in sync...
For example, let's say you have
- an
ItemService
with an array of items. - a
ItemListController
, which shows a list of items ($scope.items = ItemService.items
) - a
AddItemController
, a form to add items to the array (using the service).
When I add a new item, it doesn't automatically shows in the list controller. My workaround so far is to use cache:false
in the router so that it refreshes every time I look at it...
I can't use $scope.$apply()
because the adding happens on one controller while I want to see it on another...