javascript 未捕获的 ReferenceError:未定义模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46495162/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 06:42:32  来源:igfitidea点击:

Uncaught ReferenceError: module is not defined

javascriptangularjs

提问by jpearsonNode

As the name implies. I am experiencing an issue using the reserved keyword "Module" on bower launch. It seems to relate specifically to the code below. I cannot seem to find the exact location, as it starts at "fetch-bower.js:1". Can anyone please help me to understand how to work around this problem?

顾名思义。我在 bower 启动时使用保留关键字“模块”遇到问题。它似乎与下面的代码特别相关。我似乎找不到确切的位置,因为它从“fetch-bower.js:1”开始。任何人都可以帮助我了解如何解决这个问题吗?

(function () {
    'use strict';

angular.module('BlurAdmin.theme.components')
.directive("digitalClock", function ($timeout, dateFilter) {
        return {
            restrict: 'E',
            link: function (scope, iElement) {
                (function updateClock() {
                    iElement.text(dateFilter(new Date(), 'H:mm:ss'));
                    $timeout(updateClock, 1000);
                })();
            }
        };
    });
});

//HTML

//HTML

<div class="page-top clearfix" scroll-position="scrolled" max-height="50" ng-class="{'scrolled': scrolled}">
  <div class="row col-xs-12">
    <div class=""></div>
    <div class="aguState col-xs-3 setText">Agu State: </div>
    <div class="aguMode col-xs-3 setText">Agu Mode: </div>
    <div class="lastUpdate col-xs-3 setText">Last Update: </div>
    <digital-clock></digital-clock>
</div>

//Directive.js

//指令.js

(function () {
  'use strict';

  angular.module('BlurAdmin.theme.components')
      .directive('pageTop', pageTop);

  /** @ngInject */
  function pageTop() {
    return {
      restrict: 'E',
      templateUrl: 'app/theme/components/pageTop/pageTop.html'
    };
  }

})();

full error

完全错误

fetch-bower.js:1 Uncaught ReferenceError: module is not defined
    at fetch-bower.js:1
(anonymous) @ fetch-bower.js:1

采纳答案by Sajeetharan

Make sure you refer the angular.js and Directive.js in the index.html of the application

确保在应用程序的 index.html 中引用了 angular.js 和 Directive.js

<script src="angular.js"></script>
<script src="directive.js"></script>

also you should have empty dependencies injected to your application,

您还应该将空依赖项注入您的应用程序,

  angular.module('BlurAdmin.theme.components',[])
      .directive('pageTop', pageTop)