Debugging 在AngularJS应用程序中查找错误行
我刚开始玩AngularJS,下面是我的错误Debugging 在AngularJS应用程序中查找错误行,debugging,angularjs,Debugging,Angularjs,我刚开始玩AngularJS,下面是我的错误 Error: Argument '?' is not a function, got Object at assertArg (http://localhost/angular/project/scripts/vendor/angular.js:1039:11) at assertArgFn (http://localhost/angular/project/scripts/vendor/angular.js:1049:3) at http://lo
Error: Argument '?' is not a function, got Object
at assertArg (http://localhost/angular/project/scripts/vendor/angular.js:1039:11)
at assertArgFn (http://localhost/angular/project/scripts/vendor/angular.js:1049:3)
at http://localhost/angular/project/scripts/vendor/angular.js:4802:9
at http://localhost/angular/project/scripts/vendor/angular.js:4384:17
at forEach (http://localhost/angular/project/scripts/vendor/angular.js:137:20)
at nodeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4369:11)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4015:15)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4018:13)
at publicLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:3920:30)
at update (http://localhost/angular/project/scripts/vendor/angular.js:14202:11)
现在,我的问题是:有没有办法在.js文件中找到发生错误的行?
在引发异常时,我在angular.js文件中获得了行号,但有太多的文件
可能会发生错误
我尝试使用AngularJS Batarang,但这更多是为了调试语义错误,而不是语法错误
谢谢。如果您链接到可能导致此错误的js文件,将会更容易 从angular.js源代码中, 这看起来像是实例化控制器的问题 下面是导致断言失败的一行:
/**
* @ngdoc function
* @name ng.$controller
* @requires $injector
*
* @param {Function|string} constructor If called with a function then it's considered to be the
* controller constructor function. Otherwise it's considered to be a string which is used
* to retrieve the controller constructor using the following steps:
*
* * check if a controller with given name is registered via `$controllerProvider`
* * check if evaluating the string on the current scope returns a constructor
* * check `window[constructor]` on the global `window` object
*
* @param {Object} locals Injection locals for Controller.
* @return {Object} Instance of given controller.
*
* @description
* `$controller` service is responsible for instantiating controllers.
*
* It's just a simple call to {@link AUTO.$injector $injector}, but extracted into
* a service, so that one can override this service with {@link https://gist.github.com/1649788
* BC version}.
*/
return function(constructor, locals) {
if(isString(constructor)) {
var name = constructor;
constructor = controllers.hasOwnProperty(name)
? controllers[name]
: getter(locals.$scope, name, true) || getter($window, name, true);
=======>assertArgFn(构造函数,名称,true);
}
无法找到控制器的构造函数。是的,你是对的,我省略了控制器名称为什么没有人对此进行投票?在过去,我从不需要行号,因为我本质上知道我的代码,知道哪里会发生问题。然而,试图将代码从一个系统集成到另一个系统,我现在需要从控制台和angular中的错误中获得更好的信息是没有用的;过了一段时间,您就知道应该首先在哪里查找这些不太具有表现力的错误。不过,你提出的问题很好。我现在还不知道有什么方法可以做到这一点:(另外,Batarang在这里也没有任何帮助。它的主要用途是检查范围继承。
return $injector.instantiate(constructor, locals);
};