未知提供者:serviceProvider->服务-> myDirective [英] Unknown provider: serviceProvider -> service -> myDirective
问题描述
我正在使用的软件的最新更改使我出现以下错误:
A recent change to the software I am working on left me with the following error:
例外:错误:[$ injector:unpr]未知提供程序:tableNavigationProvider<-tableNavigation<-ajSearchSelectDirective http://errors.angularjs.org/1.4.7/ $ injector/unpr? p0 = tableNavigationProvider%20%3C-%20tableNavigation%20%3C-%20ajSearchSelectDirective"
"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?
我已经看过的站点:
- https://coderwall.com/p/eeqo7q/debugging-unknown-provider-error-in-angular
- https://docs.angularjs.org/error/ $ injector/unpr
- 角度js未知提供程序
- 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:
- 有问题的项目是调用模式的组件,以便您 可以搜索买家/业务合作伙伴
- 在新的实现上称为modal,但在同一代码的任何较旧的实现上均不调用.
-
指令的开头如下所示:
- 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
}; })();
这是服务n问题的开头:
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
}; })();
请帮助我找到问题
推荐答案
您尚未将tableNavigation
注入到ngiBusinessPartner
模块中.将您的代码更改为:
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
}; })();
注意,您的var app = angular.module('ngiBusinessPartner');
没有注入tableNavigation
模块.另外,尝试将服务或模块重命名为两个不同的名称.在您的代码中,两者相同,即tableNavigation
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
这篇关于未知提供者:serviceProvider->服务-> myDirective的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!