AngularJS:如何强制 Chrome 的开发控制台向我显示导致错误的指令?

AngularJS: How do I force Chrome's Dev Console to show me which instruction caused the error?

我经常从 angular.js、googleapi 等 "undefined is not a function".

中收到错误

问题是我不知道如何找到导致错误的指令(由我编写)。 通常我可以使用调试器,但有大量的调用,很难 difficult/long 找到原始问题。 这在使用 Google API 的缩小 js 时更加困难。

有线索吗? 提前致谢

在调试器中使用断点,或者将它放在您的代码中:

debugger;

如果控制台启动,代码将停止,帮助您一步一步地进行。 更多信息:https://developer.chrome.com/devtools/docs/javascript-debugging

另外可能,您将获得有关 chrome https://www.google.fr/chrome/browser/canary.html

开发版本的更多信息

在 Chrome DevTools 的 Sources Inspector 中,您可以按下暂停按钮(最右边的那个)。这将导致代码在出现异常之前停止,也许这可以帮助您确定问题的原因,因为您可以检查范围变量并使用控制台进一步调查调用堆栈。