简体   繁体   中英

AngularAMD fails to load controller after r.js

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM