[Widget] Debugging Assistance for Infinite Digest Loop Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello All,
I am relatively new to ServicenNow and AngularJS. I've been working on a widget and am unable to resolve the "$rootScope:infdig Infinite $digest Loop" error.
I’ve tried a couple different things that I’ve seen suggested in forums but I haven’t had any luck. I am still unsure what my core issue is such as whether my controller setup properly or if I’m using ng-repeat correctly.
I would greatly appreciate any advice.
I am using Xanadu and will attach parts of my HTML and Client Script that I believe the error to be occurring.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Good Morning @DulceK,
Debugging Angular.js within Service Portal Widgets can be tricky. Are you permitted to use an AI tool like ChatGPT or Copilot? I've found that using vibe-coding techniques can help illuminate where bugs may lie, especially with older JavaScript frameworks like Angular.js. You can try to upload your HTML template and Client script to the chatbot, along with the error and ask it questions to help you understand how to eliminate that error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Brad Steinberg I will give that a try. Thank you for the suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
You should wrap only the repeatable content with the ng-repeat directive and you shouldn't use a function call in the ng-repeat directive as the function will get called with every digest cycle causing an infinite loop as the collection changes.
<!-- Results by Table -->
<div ng-if="data.requests && data.requests.length > 0">
<div ng-repeat="request in data.requests track by $id(request)" class="table-section">
<div>{{request.number}} - {{request.title}} - {{request.status}}</div>
</div>
<!-- Table Header (Collapsible) -->
....This notation is for looping through objects and returns key value pairs. You're probably looking to loop through an array of requests (objects).
<div ng-repeat="(key, value) in myObj"> ... </div>vs.
<div ng-repeat="request in requests"> ... </div>