I've a huge jQuery plugin with domain logic from a third-party team and I really don't want to mess with its guts. This plugin exposes an object called browser
to the global namespace.
I have a simple Angular controller. I made it $watch()
the changes of browser
(using object equality, not referential equality) and update the scope accordingly:
$scope.$watch(browser, function(newValue, oldValue, scope) { scope.browser = newValue; }, true);
Fine, but now I need to do the reverse: I need to update the global browser
object when $scope.browser
model changes in the course of Angular's $digest
loop. How do I do that?
Probably, I need to create a custom hook to Angular's dirty-checking loop. I understand, that this is a bad approach and that the whole point of two-way binding was to avoid these manual callbacks, but I just can't figure out a better solution.