未知提供者:serviceProvider ->服务->我的指令 [英] 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 <- ajSearchSelectDirectivehttp://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立>
- angular 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:
- 有问题的项目是一个调用模态的组件,以便您可以搜索买家/业务合作伙伴
- 在新实现上调用模态,但不在同一代码的任何旧实现上调用.
这是指令开头的样子:
- 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
}; })();
service 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 ->服务->我的指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!