JavaScript

AngularJS: Using with RequireJS

Uncaught Error: [$injector:modulerr] Failed to instantiate module xx due to:
Error: [$injector:nomod] Module 'appname' 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.

If you use RequireJS, do not use ng-app="appname" in html tag. When used with RequireJS, Angular needs to be manually bootstrapped. Use:

var app = angular.module('appname', []); //define module
angular.bootstrap(document, ['appname']); //manually bootstrap angular, on Dom ready

Also, add this in requirejs config file:

require.config({
    shim: {
        "angular": {
            exports: 'angular'
        }
    }
});
Standard