简体   繁体   English

如何调试角度库错误?

[英]How to debug angular library error?

I'm using Angular in a website in which I just upgraded angular , angular-route and angular-ui-router to the latest bower versions. 我在一个网站中使用Angular,在该网站中,我刚刚将angularangular-routeangular-ui-router升级到了最新的Bower版本。 But suddenly I get this error in the console: 但是突然我在控制台中收到此错误:

TypeError: a.remove is not a function
    at Object.H.removeListener (main.js:7)
    at Object.b.module.service.a.removeEvents (angular-google-maps.min.js?version=2.2.1:5)
    at angular-google-maps.min.js?version=2.2.1:8
    at n.a.$get.n.$broadcast (angular.js:16311)
    at n.a.$get.n.$destroy (angular.js:15923)
    at j (angular-ui-router.min.js?version=0.2.15:7)
    at angular-ui-router.min.js?version=0.2.15:7
    at angular.js:7554
    at k (angular-ui-router.min.js?version=0.2.15:7)
    at angular-ui-router.min.js?version=0.2.15:7

The problem is now that I'm unsure of how to debug this. 现在的问题是我不确定如何调试它。 In the trace above I see two libs: angular-ui-router and angular-google-maps . 在上面的跟踪中,我看到两个库: angular-ui-routerangular-google-maps Should I start looking through the source of these libs, or is there something I'm missing in this trace which shows me how to solve this? 我应该开始浏览这些库的源代码,还是在该跟踪中缺少某些内容,这些内容向我展示了如何解决此问题?

All tips are welcome! 欢迎所有提示!

[EDIT] As suggested in the comments by @charlietfl I checked the dependencies of angular-google-maps in the bower.json file: [编辑]如@charlietfl的注释中所建议,我检查了bower.json文件中angular-google-maps的依赖项:

"dependencies": {
    "angular": "1.2 - 1.4",
    "angular-simple-logger": "~0.0.1",
    "lodash": ">=3.8.0"
},

Currently I've got: 目前我有:

  • angular version 1.4.7 角版本1.4.7
  • angular-simple-logger version 0.0.4 angular-simple-logger 0.0.4版
  • lodash version 3.10.1 lodash版本3.10.1

From this only angular-simple-logger seems to be off. 由此看来,只有angular-simple-logger似乎不可用了。 But I'm unsure what to do from here. 但是我不确定从这里做什么。 Should I downgrade angular-simple-logger to version 0.0.1, should I change "~0.0.1", to ">=0.0.1", or is there anything else I could do? 我应该将angular-simple-logger降级到0.0.1版本,还是应该将"~0.0.1",更改为">=0.0.1",或者还有其他方法可以做?

I can't see your source code, so this looks like it might be pretty specific to your application. 我看不到您的源代码,因此看起来它可能非常适合您的应用程序。 Especially with ui-router , state parameters can muck up a lot of things. 尤其是对于ui-router ,状态参数会破坏很多东西。

If this were my application, I would first turn these settings on in the Chrome debugger. 如果这是我的应用程序,那么我首先要在Chrome调试器中打开这些设置。

在此处输入图片说明

Then I would run the code and step through until the exception was thrown in angular-ui-router.min.js , since that's furthest back in the stack trace. 然后,我将运行代码并逐步执行,直到在angular-ui-router.min.js引发异常angular-ui-router.min.js ,因为这是堆栈跟踪中最远的一个。

To make things readable, you click this handy button: 要使内容可读,请单击以下便捷按钮:

使事情变得漂亮按钮

It might not be the quickest solution, but it will get you the details you need to further diagnose the problem. 它可能不是最快的解决方案,但是它将为您提供进一步诊断问题所需的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM