Reputation: 3429
I've been trying to add the angular-moment
package to my angular app but I keep getting errors after trying to include the module.
I ran bower install angular-moment --save
in the project root to install the package and verified that I was indeed loading the scripts in index.html
:
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/angular-moment/angular-moment.js"></script>
However, as soon as I add the dependency to my app definition like:
angular.module('starter', ['angularMoment', 'ionic', ...
I get a console error such as:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to: Error: [$injector:modulerr] Failed to instantiate module angularMoment due to: Error: [$injector:nomod] Module 'angularMoment' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.6/$injector/nomod?p0=angularMoment at REGEX_STRING_REGEXP (http://192.168.8.250:8100/bower_components/angular/angular.js:63:12) at http://192.168.8.250:8100/bower_components/angular/angular.js:1751:17 at ensure (http://192.168.8.250:8100/bower_components/angular/angular.js:1675:38) at module (http://192.168.8.250:8100/bower_components/angular/angular.js:1749:14) at http://192.168.8.250:8100/bower_components/angular/angular.js:4081:22 at forEach (http://192.168.8.250:8100/bower_components/angular/angular.js:322:20) at loadModules (http://192.168.8.250:8100/bower_components/angular/angular.js:4065:5) at http://192.168.8.250:8100/bower_components/angular/angular.js:4082:40 at forEach (http://192.168.8.250:8100/bower_components/angular/angular.js:322:20) at loadModules (http://192.168.8.250:8100/bower_components/angular/angular.js:4065:5) http://errors.angularjs.org/1.3.6/$injector/modulerr?p0=angularMoment&p1=Er…F192.168.8.250%3A8100%2Fbower_components%2Fangular%2Fangular.js%3A4065%3A5) at REGEX_STRING_REGEXP (http://192.168.8.250:8100/bower_components/angular/angular.js:63:12) at http://192.168.8.250:8100/bower_components/angular/angular.js:4104:15 at forEach (http://192.168.8.250:8100/bower_components/angular/angular.js:322:20) at loadModules (http://192.168.8.250:8100/bower_components/angular/angular.js:4065:5) at http://192.168.8.250:8100/bower_components/angular/angular.js:4082:40 at forEach (http://192.168.8.250:8100/bower_components/angular/angular.js:322:20) at loadModules (http://192.168.8.250:8100/bower_components/angular/angular.js:4065:5) at createInjector (http://192.168.8.250:8100/bower_components/angular/angular.js:3991:11) at doBootstrap (http://192.168.8.250:8100/bower_components/angular/angular.js:1438:20) at bootstrap (http://192.168.8.250:8100/bower_components/angular/angular.js:1459:12) http://errors.angularjs.org/1.3.6/$injector/modulerr?p0=starter&p1=Error%3A…
The angularMoment module is defined so I'm not really sure why I'm getting this error?
The full includes look like:
<!-- ionic/angularjs js -->
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/ionic/release/js/ionic.js"></script>
<script src="bower_components/ionic/release/js/ionic-angular.js"></script>
<script src="bower_components/ngCordova/dist/ng-cordova.js"></script>
<script src="bower_components/requirejs/require.js"></script>
<script src="bower_components/angular-logX/release/amd/angular-logX.js"></script>
<script src="bower_components/angular-underscore-module/angular-underscore-module.js"></script>
<script src="bower_components/underscore/underscore.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/angular-moment/angular-moment.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<!-- build:js scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers.js"></script>
<script src="scripts/services.js"></script>
<script src="scripts/configuration.js"></script>
Upvotes: 1
Views: 5783
Reputation: 3543
I think it's linked to this bug, http://github.com/urish/angular-moment/issues/36 because you have requirejs on your scripts.
[EDIT]
Has you find out, you have to move require.js
below the moment.js
include
[NOTICE]
This was originaly a comment but as it seems to be helpfull to various people I've made it has an answer for more clarity.
Upvotes: 2