向AngularJS模块添加VividCortex angular-recaptcha依赖项时出错

问题描述

我正在尝试将Google reCaptcha v2添加到我的AngularJS应用中。我正在尝试使用VividCortex的angular-captcha,但是我无法将依赖项添加到我的应用程序模块中。

我模块的原始代码是这样的:

angular.module("myApp")
.config(['$httpProvider','jwtInterceptorProvider',function Config($httpProvider,jwtInterceptorProvider) {
  //do stuff
}])

.config([ '$routeProvider','$httpProvider',function($routeProvider,$httpProvider) {
    //do other stuff
}])

.factory('httpRequestInterceptor',['API_KEY',function(API_KEY) {
    //do more stuff
}]);

我一直在尝试添加文档中的依赖项:

angular.module("myApp",['vcRecaptcha'])

但这给了我这个错误:

未捕获的错误:[$ injector:modulerr]由于以下原因,无法实例化模块myApp: 错误:[$ injector:unpr]未知提供程序:jwtInterceptorProvider

如果我不尝试添加依赖项,我不会收到此错误。

谢谢!

解决方法

问题解决了。我对AngularJS的了解不足,使我认为那是创建模块的地方,但是它只是在被检索的位置,所以当我添加依赖项时,我又在没有jwtInterceptor依赖项的情况下再次创建了它,因此出现了错误消息。 我找到了创建模块的位置,添加了依赖关系,现在它可以正常工作了。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...