Firebug:角度堆栈跟踪不显示错误的来源(行号,文件)

时间:2014-11-24 03:23:49

标签: javascript angularjs firebug stack-trace

我试图在Angular中获取堆栈跟踪,告诉我哪里出错了。相反,我只是获取错误通过Angular传播的位置列表。有时错误信息会有所帮助,但并非总是如此,但除此之外我还想知道:我想知道确切的行号以及文件名,我的代码在哪里被窃听。例如,这是典型的Firebug消息:

错误:[ng:areq] Argument' TackleController'不是函数,未定义http://errors.angularjs.org/1.3.3/ng/areq?p0=TackleController&p1=not%20a%20function%2C%20got%20undefined minErr /< @http:// localhost:63342 / fishing / bower_components / angular / angular.js:63:12 assertArg @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1560:1 assertArgFn @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1570:1 $ ControllerProvider / this。$ get< /< @http:// localhost:63342 / fishing / bower_components / angular / angular.js:8347:9 nodeLinkFn /< @http:// localhost:63342 / fishing / bower_components / angular / angular.js:7517:34 forEach @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:330:11 nodeLinkFn @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:7504:11 compositeLinkFn @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:7003:13 compositeLinkFn @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:7006:13 publicLinkFn @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:6882:30 bootstrapApply /< @http:// localhost:63342 / fishing / bower_components / angular / angular.js:1439:11 $ RootScopeProvider / this。$ get< /Scope.prototype.$eval@http:// localhost:63342 / fishing / bower_components / angular / angular.js:14204:16 $ RootScopeProvider / this。$ get< /Scope.prototype.$apply@http:// localhost:63342 / fishing / bower_components / angular / angular.js:14302:18 bootstrapApply @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1437:9调用@ http:// localhost:63342 / fishing / bower_components / angular / angular.js:4129:14 bootstrap / doBootstrap @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1435:1 bootstrap @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1455:1 angularInit @ http:// localhost:63342 / fishing / bower_components / angular / angular.js:1349:5 @http:// localhost:63342 / fishing / bower_components / angular / angular.js:25746:5触发@ http:// localhost:63342 / fishing / bower_components / angular / angular.js:2720:7 createEventHandler / eventHandler @ http:// 本地主机:63342 /钓鱼/ bower_components /角度/ angular.js:2990:9

在这种情况下,问题是我在我的HTML中引用了一个我没有定义的控制器;我发布这个作为我的意思的一个例子,不是因为我想要帮助解决这个问题。我猜它是因为Firebug会自动截断20个错误的堆栈跟踪?但是我怎么能改变它呢?

P.S。 我是Angular的菜鸟。如果这个答案在其他地方重复,请实际上将我链接到问题,而不是删除问题。

1 个答案:

答案 0 :(得分:0)

使用window.onerror获取未处理异常的详细信息:

 window.onerror = function (message, url, lineNo)
  {
  console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);

  return true;
  }

console.log(window);
console.log(1=2);

<强>参考