jpearsonNode jpearsonNode - 3 years ago 274
AngularJS Question

Uncaught ReferenceError: module is not defined

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.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'
};
}

})();


full error

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

Answer Source

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.components',[])
      .directive('pageTop', pageTop)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download