O'Reilly logo

Node.js, MongoDB, and AngularJS Web Development by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Emitting and Broadcasting Events

A great feature of scopes is the ability to emit and broadcast events within the scope hierarchy. Events allow you to send notification to different levels in the scope that an event has occurred. Events can be anything you choose, such as a value changed or threshold reached. This is extremely useful in many situations, such as letting child scopes know that a value has changed in a parent scope or vice versa.

To emit an event from a scope, you use the $emit() method. This method sends an event upward through the parent scope hierarchy. Any ancestor scopes that have registered for the event are notified. The $emit() method uses the following syntax, where name is the event name and args is zero or more arguments ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required