rfink/angular-flare — pull request #2 by akatakritos (2014-06-18 12:51:39+00:00)
Title: Fixes a $rootScope:inprog error that occurs when you fire a flash from a click event

When adding a flare from a click event, the directive calls $digest
directly, which triggers a second digest within the same cycle.

See more at the [angular docs](https://docs.angularjs.org/error/$rootScope/inprog?p0=$apply)

A simple controller such as the following is all thats needed to trigger
the error:

```js
angular.controller('MyCtrl', function($scope, flare) {
$scope.fire = function() {
flare.info("This will trigger error");
};
});
```

Binding `$scope.fire()` to an ng-click directive will cause the
following error to be spewed into the dev console:

```
Error: [$rootScope:inprog] http://errors.angularjs.org/undefined/$rootScope/inprog?p0=%24apply
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:6:453
at h (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:95:37)
at g.$get.g.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:98:16)
at onMessage (http://localhost:8081/dist/angular-flare.js:145:14)
at http://localhost:8081/dist/angular-flare.js:102:17
at Array.forEach (native)
at Object.q [as forEach] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js:7:261)
at FlareService.notify (http://localhost:8081/dist/angular-flare.js:98:11)
at FlareService.success (http://localhost:8081/dist/angular-flare.js:43:14) angular.js:9037
(anonymous function) angular.js:9037
$get angular.js:6648
$get.g.$apply angular.js:11630
(anonymous function) angular.js:17425
(anonymous function) angular.js:2555
q angular.js:300
c
```

Removing the $digest call in the directive's onMessage handler causes
the error to go away. There may be a better way to fix it, but this worked for me.