Javascript 无法实例化模块ng,因为函数($PROFECT)未使用显式批注
这里是错误:Javascript 无法实例化模块ng,因为函数($PROFECT)未使用显式批注,javascript,angularjs,Javascript,Angularjs,这里是错误: Uncaught Error: [$injector:modulerr] Failed to instantiate module ng due to: Error: [$injector:strictdi] function($provide) is not using explicit annotation and cannot be invoked in strict mode http://errors.angularjs.org/1.5.8/$injector/stric
Uncaught Error: [$injector:modulerr] Failed to instantiate module ng due to:
Error: [$injector:strictdi] function($provide) is not using explicit annotation and cannot be invoked in strict mode
http://errors.angularjs.org/1.5.8/$injector/strictdi?p0=function(%24provide)
at localhost/build/js/app-vendor.js:53360:12
at Function.annotate [as $$annotate] (localhost/build/js/app-vendor.js:57244:17)
at injectionArgs (localhost/build/js/app-vendor.js:57971:36)
at Object.invoke (localhost/build/js/app-vendor.js:58002:18)
at runInvokeQueue (localhost/build/js/app-vendor.js:57903:35)
at localhost/build/js/app-vendor.js:57912:11
at forEach (localhost/build/js/app-vendor.js:53613:20)
at loadModules (localhost/build/js/app-vendor.js:57893:5)
at createInjector (localhost/build/js/app-vendor.js:57815:19)
at doBootstrap (localhost/build/js/app-vendor.js:55050:20)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=ng&p1=Error%3A%20%5….com%3A21293%2FWebGui%2Fbuild%2Fjs%2Fapp-vendor.js%3A55050%3A20)
通常您知道该做什么:搜索未注释的函数。但是:
- 我做到了,但我找不到bug
- 我通过注释运行代码
- 堆栈跟踪没有显示任何内容,只显示角度代码
- 搜索出现的
-无效函数($provide)
var injector = createInjector(modules, config.strictDi);
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
function bootstrapApply(scope, element, compile, injector) {
scope.$apply(function() {
element.data('$injector', injector);
compile(element)(scope);
});
}]
);
return injector;
及
从我在watch window&stack trace中看到的情况来看,它发生在应用程序的某个地方,$injector.invoke以函数作为参数调用。但我诚实地搜索了所有文件,却找不到这些电话
Angular 1.5.8也出现了这种情况。我也遇到了这个问题,并发现通过禁用Chrome angularjs调试器“Batarang”解决了这个问题。有时候ng annotate需要一些帮助,添加explicit/*@ngInject*/。例如,ui路由器解析器就是这样。我知道,但我仍然分析了代码,没有找到任何这样的地方。如果这是我的常规代码,那么异常消息将有更多的细节,并准确地指向我的错误
if (!($inject = fn.$inject)) {
$inject = [];
if (fn.length) {
if (strictDi) {
if (!isString(name) || !name) {
name = fn.name || anonFn(fn);
}
throw $injectorMinErr('strictdi',
'{0} is not using explicit annotation and cannot be invoked in strict mode', name);
}
argDecl = extractArgs(fn);
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
arg.replace(FN_ARG, function(all, underscore, name) {
$inject.push(name);
});
});
}
fn.$inject = $inject;
}