我正在处理的软件最近的更改给我留下了以下错误:
"异常:错误:[$ injector:unpr]未知提供者:tableNavigationProvider< - tableNavigation< - ajSearchSelectDirective http://errors.angularjs.org/1.4.7/ $注射器/ unpr P0 = tableNavigationProvider%20%3 C-%20tableNavigation%20%3 C-%20ajSearchSelectDirective"
现在我已经查看了多个堆栈溢出板,但它们都没有任何帮助。如何找到此错误的问题?
我已查看过的网站:
在查看所有这些并正确测试(重新创建此错误)之后,您需要了解这一点:
这是指令的开头:
(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
}; })();
这就是服务n问题的开头:
(function () {
'use strict';
var app = angular.module('tableNavigation', []);
app.service('tableNavigation', [
'$document',
'$timeout',
tableNavigation
]);
function tableNavigation($document, $timeout) {
//other code goes here
}; })();
请帮我找到问题
答案 0 :(得分:0)
您尚未将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