未知提供者:serviceProvider -> service -> myDirective

Unknown provider: serviceProvider -> service -> myDirective

最近对我正在使用的软件所做的更改给我留下了以下错误:

"exception: Error: [$injector:unpr] Unknown provider: tableNavigationProvider <- tableNavigation <- ajSearchSelectDirective http://errors.angularjs.org/1.4.7/$injector/unpr?p0=tableNavigationProvider%20%3C-%20tableNavigation%20%3C-%20ajSearchSelectDirective"

现在我已经查看了多个堆栈溢出板,但其中 none 个对我有帮助。我如何找到这个错误的问题?

我已经看过的网站:

在查看了所有这些内容并进行了适当的测试(以重现此错误)之后,您需要知道以下内容:

请帮我找出问题所在

您还没有将 tableNavigation 注入到您的 ngiBusinessPartner 模块中。将您的代码更改为:

(function () {
var app = angular.module('ngiBusinessPartner',['tableNavigation']);
app.directive('ajSearchSelect', [
  '$timeout',
  'uiStateMachine',
  'formHelper',
  'spinnerService',
  'tableNavigation',
  ajSearchSelect]);

function ajSearchSelect(
$timeout,
uiStateMachine,
formHelper,
spinnerService,
tableNavigation) {
//other code goes here
}; })();

请注意,您的 var app = angular.module('ngiBusinessPartner'); 未注入 tableNavigation 模块。此外,尝试将服务或模块重命名为两个不同的名称。在您的代码中,两者相同,即 tableNavigation