Search code examples
javascriptangularjsrequirejsangular-amd

AngularAMD loading module does not work


I'm trying to use angularAMD for a new project, but i can't get it to work.

i have the following:

main.js

require.config({
   baseUrl: "static/",
   paths: {
       'angular': 'bower_components/angular/angular',
       'angularAMD': 'bower_components/angularAMD/angularAMD',
       'ngload': 'bower_components/angularAMD/ngload',
       'ui-router': 'bower_components/angular-ui-router/release/angular-ui-router'
    },
    shim: {
       'ui-router': ['angular'],
       'angularAMD': ['angular'],
       'ngload': ['angularAMD']
    },
   deps: ['js/app']
});

app.js

define(['angularAMD', 'ui-router'], function (angularAMD) {
    var app = angular.module('app', ['ui-router']);
    return angularAMD.bootstrap(app);
});

index.html script tag

<script type="text/javascript" data-main="/static/js/main.js" src="/static/bower_components/requirejs/require.js"></script>

The issue is that i keep getting the Module Unavailable error.

I'm probably doing something wrong, but if i check the example on the angularAMD homepage my setup seems alright..

Hope someone can give me a solution!


Solution

  • I made a mistake with the module name i injected, it was supposed to be 'ui.router' instead of 'ui-router'.