focusing (from angular context) on an element which has ngFocus will cause '$apply already in progress' exception #6791
Description
Hi,
If we'll focus on an element from angular context, and that element has ngFocus, we will get '$apply already in progress' exception. You can see it happen in the following plunkr:
http://plnkr.co/edit/R6ZDD8kVGu3SpzHY4CVT?p=preview **
Focusing and blurring with the cursor works fine, like it should. However when clicking on the 'Click to focus on input' button, we will get the exception (see console).
This issue can be solved in the directives of ngFocus, ngBlur and the rest of the events by checking if digest is already in progress (scope.$root.$$phase). However, I don't think that checking digest state on a plain directive is the 'angular way' of doing things, so maybe I'm missing something here. If you do think it's the way to do it, I don't mind writing it.
** I know that fiddling with DOM on the controller is bad practice, it's just to keep the example simple, it can be easily reproduced on a better-practice directive with an ngClick handler that does the same thing.