如何调试此 AngularJS 代码?

6 浏览
0 Comments

如何调试此 AngularJS 代码?

当angular内部出现错误时,我似乎无法进行调试。我有这段代码:


它抛出以下错误:

    angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.6/$injector/modulerr?p0=campaign_listing&p1…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.6%2Fangular.min.js%3A19%3A463)
And without the minified version:
Uncaught Error: [$injector:modulerr] Failed to instantiate module campaign_listing due to:
Error: [$injector:modulerr] Failed to instantiate module $http due to:
Error: [$injector:nomod] Module '$http' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.6/$injector/nomod?p0=%24http

我没有使用路由,所以那个链接实际上让我感到困惑。

有人能告诉我问题是什么以及如何在未来调试它吗?

admin 更改状态以发布 2023年5月21日
0
0 Comments

之前的答案是正确的,但是当您没有包含控制器文件时,也可能会发生这种情况。下面的示例显示在第60行我已经注释了控制器文件,但在第13行实际上正在引用AppCtrl。如果我取消注释第60行,则错误会消失。

enter image description here

这是您在控制台上得到的内容:enter image description here

0
0 Comments

你可以在my_app.controller()的那行代码中创建一个断点,并进入Angular代码(祝你好运,对于初学者来说很难)。

仅凭阅读你的代码,我建议尝试这样做:


我猜你后面可能会遇到更多问题,因为这看起来不太像典型的Angular代码。我的建议是:先尝试进行教程练习。

0