简体   繁体   中英

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. 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 . 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:

"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
  • angular-simple-logger version 0.0.4
  • lodash version 3.10.1

From this only angular-simple-logger seems to be off. 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?

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.

If this were my application, I would first turn these settings on in the Chrome debugger.

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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