Benefit of this solution:
- You only need one bind to
$(document)
. Other firing of events would depend on the$emit
of scope events. - You could use both expressions
click-elsewhere="show=false"
, andclick-elsewhere="fn()"
, thanks to$parse
.
Usage in HTML:
Same with ng-click:
click-elsewhere="fn()"
click-elsewhere="show=false"
A little bit on $parse:
Basically what $parse does is that it converts Angular expression into a function, which could then be called with the scope you want applied to. It’s probably about the entrance to Angular’s magic 🙂