调试 – 在AngularJS应用程序中查找错误行
发布时间:2020-12-17 07:36:29 所属栏目:安全 来源:网络整理
导读:我刚刚开始玩AngularJS,我在下面有错误. Error: Argument '?' is not a function,got Objectat assertArg (http://localhost/angular/project/scripts/vendor/angular.js:1039:11)at assertArgFn (http://localhost/angular/project/scripts/vendor/angular.
我刚刚开始玩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://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文件中找到错误发生的行? 我尝试使用AngularJS Batarang,但这更适用于调试语义不是语法错误. 谢谢.
如果您链接到导致此错误的js文件将会更容易.
来自angular.js源码,https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/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,true); ======> assertArgFn(constructor,true); return $injector.instantiate(constructor,locals); }; 它无法找到控制器的构造函数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |