首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS错误:$注入器调制器

AngularJS错误:$注入器调制器
EN

Stack Overflow用户
提问于 2015-11-04 14:24:42
回答 2查看 862关注 0票数 0

我试图运行一个简单的客户关系管理应用程序,基于平均堆栈网页。加载页面时,控制台中会出现以下错误:

代码语言:javascript
复制
Error: [$injector:modulerr] http://errors.angularjs.org/1.4.7/$injector/modulerr?p0=userApp&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.7%2F%24injector%2Fmodulerr%3Fp0%3DuserCtrl%26p1%3D%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.4.7%252F%2524injector%252Fnomod%253Fp0%253DuserCtrl%250AI%252F%253C%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A6%253A416%250Ade%252F%253C%252F%253C%252F%253C%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A24%253A186%250Aa%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A23%253A252%250Ade%252F%253C%252F%253C%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A23%253A1%250Ah%252F%253C%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A37%253A427%250Am%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A7%253A320%250Ah%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A37%253A275%250Ah%252F%253C%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A37%253A444%250Am%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A7%253A320%250Ah%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A37%253A275%250Afb%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A41%253A35%250Azc%252Fd%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A19%253A463%250Azc%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A20%253A274%250AZd%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A19%253A83%250A%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A293%253A238%250Aa%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A174%253A399%250AHf%252Fc%2540http%253A%252F%252Flocalhost%253A8080%252Fassets%252Flibs%252Fangular%252Fangular.min.js%253A35%253A212%250A%0AI%2F%3C%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A6%3A416%0Ah%2F%3C%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A38%3A184%0Am%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A7%3A320%0Ah%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A37%3A275%0Ah%2F%3C%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A37%3A444%0Am%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A7%3A320%0Ah%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A37%3A275%0Afb%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A41%3A35%0Azc%2Fd%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A19%3A463%0Azc%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A20%3A274%0AZd%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A19%3A83%0A%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A293%3A238%0Aa%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A174%3A399%0AHf%2Fc%40http%3A%2F%2Flocalhost%3A8080%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A35%3A212%0A


angular.min.js (line 6, col 416)

这是我的app.js文件(主应用程序模块)

代码语言:javascript
复制
angular.module('userApp', [
    'ngAnimate',
    'app.routes',
    'authService',
    'mainCtrl',
    'userCtrl',
    'ngRoute',
    'userService'
    ]);

我的index.html:

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>User CRM</title>
        <base href="/">

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.5/custom/bootstrap.min.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.min.css">
        <link rel="stylesheet" href="assets/cs/style.css">

        <script type="text/javascript" src="assets/libs/angular/angular.min.js"></script>
        <script type="text/javascript" src="assets/libs/angular-route/angular-route.min.js"></script>
        <script type="text/javascript" src="assets/libs/angular-animate/angular-animate.min.js"></script>

        <script type="text/javascript" src="app/controllers/mainCtrl.js"></script>
        <script type="text/javascript" src="app/controllers/userCtrl.js"></script>

        <script type="text/javascript" src="app/services/authService.js"></script>
        <script type="text/javascript" src="app/services/userService.js"></script>

        <script type="text/javascript" src="app/app.routes.js"></script>
        <script type="text/javascript" src="app/app.js"></script>
    </head>

    <body ng-app="userApp" ng-controller="mainController as main">
        <header>
            <div class="navbar navbar-inverse" ng-if="main.loggedIn">
                <div class="container">
                    <div class="navbar-header">
                        <a href="/" class="navbar-brand"><span class="glyphicon glyphicon-fire text-danger"></span> User CRM</a>
                    </div>
                    <ul class="nav navbar-nav">
                        <li><a href="/users"><span class="glyphicon glyphicon-user"></span> Users</a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li ng-if="!main-loggedIn"><a href="/login">Login</a></li>
                        <li ng-if="main.loggedIn" class="navbar-text">Hello {{ main.user.name }}!</li>
                        <li ng-if="main.loggedIn"><a href="#" ng-click="main.doLogout()">Logout</a></li>
                    </ul>
                </div>
            </div>
        </header>
        <main class="container">
            <div ng-view></div>
        </main>
    </body>
</html>

我已经使用bower (角、角路由、角动画)加载了本地依赖项,其余的都是本地.js文件,所以我无法真正找出问题所在。

整个项目可以在这个Git Repo上找到。代码的角部分位于/public文件夹中。

任何反馈/想法都值得赞赏。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-11-04 14:31:19

你试图在你的应用程序中注入userCtrl,我在git中找不到它。

代码语言:javascript
复制
angular.module('userApp', [
'ngAnimate',
'app.routes',
'authService',
'mainCtrl',
'userCtrl',
'ngRoute',
'userService'
]);

角DI,是寻找一个服务/控制器/工厂,任何组件的名称userCtrl,但它找不到。

角DI不查找文件,而是使用组件的字符串名称的组件。

票数 0
EN

Stack Overflow用户

发布于 2015-11-04 14:34:08

控制器和服务必须是userApp模块的一部分,而不是分离MainCtrluserService模块。

变化

代码语言:javascript
复制
// This declares a new module named 'mainCtrl'
angular.module('mainCtrl', [])

angular.module('userService', [])

angular.module('autService', [])

代码语言:javascript
复制
angular.module('userApp')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33524336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档