Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS: How to debug the 'App Already Bootstrapped with this Element' error

In my AngularJS app I'm getting the follwing error when loading my site:

Uncaught Error: [ng:btstrpd] App Already Bootstrapped with this Element '<html lang="en" ng-app="app" class="ng-scope">'

I have ng-app only set once (in html element in _Layout.cshtml (ASP.NET MVC)) and I don't use angular.bootstrap so the issue mentioned here should not apply. How can debug the issue (using F12, Firebug, Chrome...)?

like image 304
Dunken Avatar asked Nov 02 '22 06:11

Dunken


1 Answers

Use the following process:

  • Download the unminified Angular source
  • Switch the script tag to reference the unminified Angular source or setup a sourcemap from the minified code to the unminified
  • Set a breakpoint within the angular.bootstrap method definition
  • Use the call stack to trace the source(s) on the call(s)

References

  • Use a source map - Firefox Developer Tools | MDN

  • F12 devtools guide: Debugger | Source Maps - Microsoft Edge Development

  • Map Preprocessed Code to Source Code  |  Web  |  Google Developers

  • Chromium Issue 611328 - Failed to parse SourceMap

  • evanw/node-source-map-support: Adds source map support to node.js (for stack traces)

like image 98
Paul Sweatte Avatar answered Nov 11 '22 13:11

Paul Sweatte