angular/angular.js — pull request #9892 by NotBobTheBuilder (2014-11-03 21:13:32+00:00)
Title: Feature hooks for ng events

Review needed/ not merge ready (due to lack of docs).

This adds a mechanism for hooking into ngClick/Touch/Mouseover etc. events, so that directives can cancel events or view the result of the handler call.

My use case: I wanted to create a `button` directive which disables the button/changes it to a loading state if the ng-click handler returns a promise.

This can be achieved now by `require`ing `ngClick` in the directive, and hooking the state changes into a function pushed to `$callResultWatchers`.

`$interceptors` hold functions which are called before the handler, and can cancel the event with exactly and only a `return false;`.

Would love feedback on the design & implementation.

Thanks!