Jess Jordan Jess Jordan - 2 months ago 11
AngularJS Question

$scope.on in angularjs and binding it with an event

$scope.$on('properties:update', function (event, properties) {
$ = properties;

What does the above code does? I did not see any
method elsewhere in the controller and in the view. Above event only trigger once upon entering the page. How to trigger it programmatically?


This method is used for communicating between controllers. Like two controllers in one application can communicate with each other through broadcast and on handlers. See the below example.

The event broadcaster a different controller

$rootScope.$broadcast('showMenu', $scope.ticket_items);

The event reciever is as follows

    $scope.ticketVisible = false;
    $scope.ticket_items = ticket_items;