Closed elinfante closed 9 years ago
Given the setTimeout
s, this does sound like a digest-related issue to me.
What sort of configuration are you loading? How is it impacting what's getting shown in your view? You imply that you're using multiple controllers: is one a child of the other, and have you ensured that you're calling $scope.$apply
on the correct one based on the view you're updating? Having some more context (and code) should make it easier to help root this out.
@elinfante Have you tried $scope.$evalAsync()
instead?
I am trying to load a json file with some configuration in it. That should do it every 10 seconds, but not sure why the view of a directive does not get updated until that file is loaded. There is no connection whatsoever (or at least that is what I think).
I have tried $scope.$evalAsync() and that does not seem to solve the issue.
I will try to explain with more detail:
The config json file it is loaded every 10secs like this:
Timer.setTimeout (_loadMainConfig, s*1000);
Then on the other hand I have a Directive with Isolated Scope. I have 2 way binding attributes in the directive. It seems the Controller updates the value but not the Isolated Scope in the directive.
I did a test in my view and I can see the following:
Header: Ctrl-> 20 Directive -> NaN
If I put the $scope.$apply() in the directive, I get the $digest in progress error. When the config json file is loaded I can see straight away how the Nan turns into 20. I do not understand the relationship between the Timeout and the update of the Isolated Scope in the directive.
I am new to angular, so bear with me If I did/said something that does not make much sense.
Thanks!
Hi @elinfante, Is this still a valid issue? Thanks - Jordan
Hi,
I have a setTimeout interval to keep loading different config files. That runs every second. It looks like this:
The problem comes when in another Controller I update the $scope correctly (I can console log the values) but the view does not get updated until a new setTimeout is called (every second). Why is it doing that, I am banging my head against the wall!
I have tried using $scope.apply but that does not seem to solve the problem.
Thanks!