AngularAMD fails to load controller after r.js

86 Views Asked by At

It seems like I miss running r.js over code with AngularAMD.

.when('/', angularAMD.route({
    templateUrl: 'views/home.html',
    controller: 'HomeCtrl',
    controllerUrl: 'controllers/home',
    data: {
          name: 'home'
    }
}))

I have the following route defined which works fine as long as I don't run r.js, but after I do I'm getting the following error,

Uncaught Error: undefined missing controllers/home
1

There are 1 best solutions below

0
On

Is the name of your js file for the home controller named home.js?

If not - then you will want the controllerUrl to equal the exact name without the .js at the end. - controllers/homeCtrl or controllers/homeController - mattering if that is how you've named your controller's js file.