Unknown provider: serviceProvider

A recent change to the software I am working on left me with the following error:

"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"

Now I have looked at multiple stack overflow boards but none of them is any help. How do I find the problem with this error?

Sites that I already looked at:

  • https://coderwall.com/p/eeqo7q/debugging-unknown-provider-error-in-angular
  • https://docs.angularjs.org/error/$injector/unpr
  • angular js unknown provider
  • After looking at all these and properly testing (to recreate this error), this is what you need to know:

  • The item in question is a component that calls up a modal so that you can search a buyer/businessPartner
  • On the new implementation is calls the modal but not on any of the older implementations of the same code.
  • This is what the start of the directive looks like:

    (function () {
    var app = angular.module('ngiBusinessPartner');
    app.directive('ajSearchSelect', [
    '$timeout',
    'uiStateMachine',
    'formHelper',
    'spinnerService',
    'tableNavigation',
    ajSearchSelect]);
    
    function ajSearchSelect(
    $timeout,
    uiStateMachine,
    formHelper,
    spinnerService,
    tableNavigation) {
    //other code goes here
    }; })();
    
  • This is what the start of the service n question looks like:

    (function () {
    'use strict';
    
    var app = angular.module('tableNavigation', []);
    
    app.service('tableNavigation', [
    '$document',
    '$timeout',
    tableNavigation
    ]);
    function tableNavigation($document, $timeout) {
    //other code goes here
    }; })();
    
  • Please help me find the problem


    You havent injected tableNavigation into your ngiBusinessPartner module. Change your code to :

    (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
    }; })();
    

    Note, your var app = angular.module('ngiBusinessPartner'); is not getting injected with tableNavigation module. Also, try to rename service or module to two different names. In your code, both are same ie tableNavigation

    链接地址: http://www.djcxy.com/p/77646.html

    上一篇: 我该如何解决这个httpProvider错误?

    下一篇: 未知提供者:serviceProvider