Here is something that might save a few painstaking hours. While working on an AngularJS code in a web page, there was a need to pass some data from the server side for the initialization. Since the data was static and the page already had previous functionality, the easiest way was to dump the data in the form of JSON straight into the page when it was being rendered on the server side. Then, in Angular code this JSON data would be used when the code runs on the client side.
So, after a few changes the annoying "Error: $digest already in progress" error was popping up as soon as the dialog was loaded. Oh, right, another thing was that there was a dialog that was dynamically loaded from the server depending on what the user clicked. Then, each dialog had its own Angular controller.
To make the story short, the JSON initialization in a script tag was placed *inside* the div with ng-controller. This was triggering the exception as it messed up with Angular code, I guess.
Moving the script tag above the div with ng-controller helped and now the code works as expected.
So, after a few changes the annoying "Error: $digest already in progress" error was popping up as soon as the dialog was loaded. Oh, right, another thing was that there was a dialog that was dynamically loaded from the server depending on what the user clicked. Then, each dialog had its own Angular controller.
To make the story short, the JSON initialization in a script tag was placed *inside* the div with ng-controller. This was triggering the exception as it messed up with Angular code, I guess.
Moving the script tag above the div with ng-controller helped and now the code works as expected.
No comments:
Post a Comment