I'm attempting to update the main nav bar with the user's name, and also update the shopping cart icon with how many items he's bought. I haven't tried using $broadcast and $on before.
On successful post of a log in I set up a simple broadcast, this is in its own login controller:
$rootScope.$broadcast('user-logged-in');
Now I have the $on event in the controller where the shopping cart icon resides, but the value is never updated upon log in. In fact, I don't even get the console message, so it just never gets to it.
$scope.$on('user-logged-in', function (event, args) {
console.log("Broadcasted to Products Controller");
$scope.logged= Session.isLogged();
$scope.username= Session.recallName();
});
Learning how to use this would be very helpful, because there is lots more I keep to update on the main view when data in other views change. If it makes a difference I'm using UI-Router.