What\'s the correct way to communicate between controllers?
I\'m currently using a horrible fudge involving window
:
function StockSubgro
Here's the quick and dirty way.
// Add $injector as a parameter for your controller
function myAngularController($scope,$injector){
$scope.sendorders = function(){
// now you can use $injector to get the
// handle of $rootScope and broadcast to all
$injector.get('$rootScope').$broadcast('sinkallships');
};
}
Here is an example function to add within any of the sibling controllers:
$scope.$on('sinkallships', function() {
alert('Sink that ship!');
});
and of course here's your HTML: