Thursday, January 21, 2016

Next Interview Question
Home

$emit, $on, $broadcast in AngularJs

$emit(): It is used by a child scope to communicate to its parent. In the above example ,Second Controller can be used to communicate to its parent scope which is the First Controller. Similarly , the Third Controller can be used to communicate to its parent which is $rootScope.All other scope are descendants to $rootscope.
$on(): It is used to catch the events that are dispatched from $emit or $broadcast.
$broadcast: It dispatches an event to its all descendants. The Third Controller will communicate to the First Controller using broadcast. It sends an event to the rootscope which broadcasts it, which in turn is caught by the First Controller.


Next Interview Question
Home

0 comments :

Post a Comment