I have a situation in my application where I need to reload the menu each time the role of the user changes(One user can have roles in several companies).
I was wond
$watch()
is doing dirt-checking: the function makes a comparison each digest cycle. On the other hand, $broadcast()
propagates an event only when there is one. Naturally, $broadcast()
is cheaper than $watch()
.
But did you really have to worry about performance here? One primitive comparison by cycle is nothing. However, conceptually, $watch()
is clearly what you need: you want to do an action each time a variable changes. I can't imagine using $broadcast()
here.