Calls fn
with or without scope.$apply()
, depending on if current thread is already inside $apply()
. For AngularJS.
As a component
$ component install hugojosefson/apply-safely-for-angular
With Bower
$ bower install hugojosefson-apply-safely-for-angular
require("applySafely");
// Example use
angular.module("yourModule", []).controller("yourController", function($scope, applySafely) {
someNonAngularCodeWhichCallsBack("params", function callback(result) {
applySafely($scope, function() {
$scope.result = result;
});
});
});
MIT