最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught ReferenceError: module is not defined - Stack Overflow

programmeradmin1浏览0评论

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?

(function () {
    'use strict';

angular.module('BlurAdmin.themeponents')
.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.themeponents')
      .directive('pageTop', pageTop);

  /** @ngInject */
  function pageTop() {
    return {
      restrict: 'E',
      templateUrl: 'app/theme/ponents/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

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?

(function () {
    'use strict';

angular.module('BlurAdmin.theme.ponents')
.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.ponents')
      .directive('pageTop', pageTop);

  /** @ngInject */
  function pageTop() {
    return {
      restrict: 'E',
      templateUrl: 'app/theme/ponents/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
Share edited Sep 29, 2017 at 18:49 jpearsonNode asked Sep 29, 2017 at 18:42 jpearsonNodejpearsonNode 611 gold badge4 silver badges13 bronze badges 6
  • @Jax No good, threw a whole list of warnings, but the error still remains in the browser. – jpearsonNode Commented Sep 29, 2017 at 18:46
  • post your plete code with references – Sajeetharan Commented Sep 29, 2017 at 18:46
  • try angular.module('BlurAdmin.theme.ponents', []) as stated in the angular docs. – Jax Commented Sep 29, 2017 at 18:46
  • @PatrickEvans To clarify, the browser tools are showing the issue. Pointing to Bower launch position 1 – jpearsonNode Commented Sep 29, 2017 at 18:48
  • are you refering the directive in index.html – Sajeetharan Commented Sep 29, 2017 at 18:53
 |  Show 1 more ment

1 Answer 1

Reset to default 0

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

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

also you should have empty dependencies injected to your application,

  angular.module('BlurAdmin.theme.ponents',[])
      .directive('pageTop', pageTop)
发布评论

评论列表(0)

  1. 暂无评论