简体   繁体   English

错误:$ injector:modulerr模块错误似乎我的指令中存在注入错误,但我不明白我的代码有什么问题

[英]Error: $injector:modulerr Module Error seems there is an injection error in my directive but I don't understand whats wrong in my code

It seems there is an injection error in my directive but I don't understand whats wrong in my code and other posts in that issue didn't really help me figure that out. 我的指令中似乎存在注入错误,但是我不明白我的代码中有什么问题,而该问题中的其他帖子并没有真正帮助我弄清楚这一点。 Anyone has an idea? 有人有主意吗? Happy about any suggestions! 满意任何建议! Thanks!!! 谢谢!!!

my index.html 我的index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Flash Cards</title>
        <link rel="stylesheet" type="text/css" href="css/reset.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <script src="angular.min.js"></script>
        <script src="js/app.js"></script>
        <script src="js/navbar/navbar.js"></script>
        <script src="js/home/home.js"></script>
        <script src="js/about/about.js"></script>
    </head>
    <body ng-app="flashCards" >
        <navbar></navbar>
   hello
    </body>
</html>

my directive: 我的指令:

app.directive('navbar', function ($rootScope, $state) {
  return {
    restrict: 'E',
    scope: {},
    templateUrl: 'js/navbar/navbar.html',
    link: function (scope) {

        scope.items = [
            { label: 'Home', state: 'home' },
            { label: 'Unsere Praxis', state: 'about' },
            // { label: 'Leistungen', state: 'docs' },
            //  { label: 'Sprechstunden', state: 'sprechstunden' },
            //   { label: 'Kontakt', state: 'kontakt' },
            //    { label: 'Termin buchen', state: 'book' }

        ];

    }

  };
});

navbar html 导航栏html

<nav class="navbar navbar-static-top">
   <div class="container">
     <div class="navbar-header">
        <fullstack-logo></fullstack-logo>
    </div>
    <ul class="nav navbar-nav">
        <li ng-repeat="item in items">
            <a ui-sref-active="active" ui-sref="{{ item.state }}">{{ item.label }}</a>
        </li>

    </ul>
    <button ng-show="!user" ui-sref="login" class="btn login-button">Login</button>
    <div ng-show="user" class="welcome">
        <span>Welcome, {{ user.email }}!</span>
        <a >Logout</a>
    </div>
  </div>
</nav>

I guess it is hard to say for sure without trying it myself, but here is a possibility: 我想很难不自己尝试就确定地说,但这是有可能的:

What is this $state you use in: 您在以下位置使用的$state是什么:

app.directive('navbar', function ($rootScope, $state) {

Is this the $state of ui router ? 这是ui路由器$state吗? If so maybe you are missing a link to angular-ui-router.js , something like: 如果是这样,也许您缺少指向angular-ui-router.js的链接,例如:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-beta.2/angular-ui-router.js"></script>

Also don't forget to make sure you added a dependency to your application module: 另外,请不要忘记确保已向应用程序模块添加了依赖项:

angular.module('app', ['ui.router']);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS错误:$ injector:modulerr浏览器窗口中的模块错误 - AngularJS Error: $injector:modulerr Module Error in my browser window 错误:$ injector:modulerr模块错误(我的第一个SPA应用程序) - Error: $injector:modulerr Module Error (my first SPA app) 错误:$ injector:modulerr模块错误 - Error: $injector:modulerr Module Error 错误:$injector:modulerr 模块错误 - Error: $injector:modulerr Module Error 我的代码有什么问题? 我没有得到错误; 我没有得到任何回应 - Whats wrong with my code? I don't get an error; I get no response what so ever 我的控制台中的错误-[$ injector:modulerr]由于以下原因而无法实例化模块启动器:[$ injector:nomod]模块&#39;starter&#39;不可用 - Error in my console - [$injector:modulerr] Failed to instantiate module starter due to: [$injector:nomod] Module 'starter' is not available Angular $ injector:modulerr模块错误 - Angular $injector:modulerr Module Error 我不理解代码中的语法错误 - I don't understand the syntax error in my code 得到错误“错误:$ injector:modulerr模块错误” - Getting error “Error: $injector:modulerr Module Error” 未捕获的错误:[$ injector:modulerr] http://errors.angularjs.org/1.6.6/$injector/modulerr?p0仍然无法正常工作,请检查我的代码 - Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.6/$injector/modulerr?p0 Still not working please Check my code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM