0

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:

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

Scrumptious
  • 17
  • 10

1 Answers1

0

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 i.e. tableNavigation

Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104