未知提供者:serviceProvider -> service -> myDirective
Unknown provider: serviceProvider -> service -> myDirective
最近对我正在使用的软件所做的更改给我留下了以下错误:
"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"
现在我已经查看了多个堆栈溢出板,但其中 none 个对我有帮助。我如何找到这个错误的问题?
我已经看过的网站:
- https://coderwall.com/p/eeqo7q/debugging-unknown-provider-error-in-angular
- https://docs.angularjs.org/error/$injector/unpr
- angular js unknown provider
在查看了所有这些内容并进行了适当的测试(以重现此错误)之后,您需要知道以下内容:
- 有问题的项目是调用模态的组件,以便您
可以搜索一个buyer/businessPartner
- 在新的实现中调用模态,但在相同代码的任何旧实现中都没有。
指令的开头是这样的:
(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
}; })();
请帮我找出问题所在
您还没有将 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
最近对我正在使用的软件所做的更改给我留下了以下错误:
"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"
现在我已经查看了多个堆栈溢出板,但其中 none 个对我有帮助。我如何找到这个错误的问题?
我已经看过的网站:
- https://coderwall.com/p/eeqo7q/debugging-unknown-provider-error-in-angular
- https://docs.angularjs.org/error/$injector/unpr
- angular js unknown provider
在查看了所有这些内容并进行了适当的测试(以重现此错误)之后,您需要知道以下内容:
- 有问题的项目是调用模态的组件,以便您 可以搜索一个buyer/businessPartner
- 在新的实现中调用模态,但在相同代码的任何旧实现中都没有。
指令的开头是这样的:
(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 }; })();
请帮我找出问题所在
您还没有将 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