【问题标题】:Error adding VividCortex angular-recaptcha dependency to AngularJS module将 VividCortex angular-recaptcha 依赖项添加到 AngularJS 模块时出错
【发布时间】:2020-08-18 22:14:01
【问题描述】:

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

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

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 recaptcha


    【解决方案1】:

    问题解决了。我对 AngularJS 缺乏了解,这让我认为这是创建模块的地方,但它只是被检索,所以当我添加依赖项时,我再次创建它而没有 jwtInterceptor 依赖项,因此出现错误消息。 我找到了模块的创建位置,添加了依赖项,现在它可以工作了。

    【讨论】:

      猜你喜欢
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      相关资源
      最近更新 更多