【发布时间】:2018-09-29 12:50:20
【问题描述】:
最近对我正在开发的软件的更改给我留下了以下错误:
“异常:错误:[$injector:unpr] 未知提供者:tableNavigationProvider http://errors.angularjs.org/1.4.7/$injector/unpr?p0=tableNavigationProvider%20%3C-%20tableNavigation%20%3C-%20ajSearchSelectDirective"
现在我查看了多个堆栈溢出板,但它们都没有任何帮助。如何找到此错误的问题?
我已经看过的网站:
- https://coderwall.com/p/eeqo7q/debugging-unknown-provider-error-in-angular
- https://docs.angularjs.org/error/$injector/unpr
- angular js unknown provider
查看所有这些并正确测试(重新创建此错误)后,您需要了解以下内容:
- 有问题的项目是一个调用模式的组件,以便您 可以搜索买家/业务合作伙伴
- 在新实现上调用模态,但不在同一代码的任何旧实现上。
-
这是指令开头的样子:
(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 }; })();
请帮我找出问题
【问题讨论】:
-
你在index.html中添加了.js文件吗?
-
哪个 .js 文件?指令还是服务?
-
服务。角度无法找到注入指令的服务文件。此外,您提供的代码 sn-p 都是
directives而不是service -
抱歉混淆了我实际上为服务使用了错误的代码
-
但是 .js 被添加到 index.html 中
标签: angularjs web service angularjs-directive