I've encountered an issue with my Angular service that updates the $rootScope. The actual updating process works as intended, but it triggers an error in the console that has me concerned.
app.service("scroll", function($rootScope, $window) {
this.scrolling = function(delta){
$rootScope.scroll.current -= delta;
}
$rootScope.$apply();
});
Removing the $rootScope.$apply()
eliminates the error, but then the rootScope value doesn't seem to update when referenced in my HTML.
For instance, in my HTML:
{{scroll.current}}
Only updates when using $rootScope.$apply()
. Is there a more effective method for updating the $rootScope or am I overlooking something?
Error message displayed:
Error: [$rootScope:inprog] http://errors.angularjs.org/1.3.0-rc.5/$rootScope/inprog?p0=%24apply