Based on code from https://github.com/yearofmoo/AngularJS-Scope.SafeApply
- Open bower.json
- Add
"angular-safeapply": "~1.0.0"to your dependency list - Run
bower install - In your application you can now add:
<script src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fcomponents%2Fangular-safeapply%2Fsafe-apply.js"></script>
Add SafeApply to your apps module dependancy list then
- on any scope:
$scope.$safeApply(function() { optionalFunction; }); - or used as a service:
$safeApply($scope, function() {});