未捕获的ReferenceError:未定义模块

时间:2017-09-29 18:42:47

标签: javascript angularjs

顾名思义。在bower启动时使用保留关键字“Module”时遇到问题。它似乎与下面的代码有关。我似乎无法找到确切的位置,因为它从“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

<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

(function () {
  'use strict';

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

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

})();

完整错误

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

1 个答案:

答案 0 :(得分:0)

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

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

你也应该为你的应用程序注入空的依赖项,

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