I'm having an issue creating an AngularJS module inside a RequireJS define method.
When I make reference to the ui-router module that I need, Angular tells me:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' 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.
This only happens if I define uiRouter
in the requireJS dependency list.
Here's my code:
require.config({
paths : {
'angular' : "/script/lib/angular",
'uiRouter' :"/script/lib/angular-ui-router",
},
shim : {
'angular': {
exports : 'angular'
},
'uiRouter' : {
deps : ['angular']
}
}
});
define(['angular', 'uiRouter'], function (angular) {
var module = angular.module('myApp', []);
});
If I take uiRouter
out of the define dependency array, everything works as expected. What am I doing wrong?