Listen on events of a given type. See $emit
for discussion of
event life cycle.
angular.scope.$on(name, listener);
name – {string} –
Event name to listen on.
listener – {function(event)} –
Function to call when the event is emitted.
{function()}
– Returns a deregistration function for this listener.
The event listener function format is: function(event)
. The event
object passed into the
listener has the following attributes
- targetScope
- {Scope}: the scope on which the event was $emit
-ed or $broadcast
-ed.
- currentScope
- {Scope}: the current scope which is handling the event.
- name
- {string}: Name of the event.
- cancel
- {function=}: calling cancel
function will cancel further event propagation
(available only for events that were $emit
-ed).