While setting up my AngularJS app with AngularAMD (a RequireJS implementation for AngularJs), I have encountered an issue:
Cannot read property 'bootstrap' of undefined(…)
main.js
require.config({
paths: {
//Angular
'angular': '/bower_components/angular/angular',
'angular-route': '/bower_components/angular-route/angular-route.min',
'angularAMD': '/bower_components/angularAMD/angularAMD.min',
'angular-slick': '/bower_components/angular-slick/dist/slick.min',
'angular-sanitize': '/bower_components/angular-sanitize/angular-sanitize',
//Plugins
'jquery': '/bower_components/jquery/dist/jquery',
'materialize': '/bower_components/Materialize/dist/js/materialize.min',
'jquery-hammer': '/bower_components/Materialize/js/jquery.hammer',
'hammerjs': '/bower_components/Materialize/js/hammer.min',
'parallax': '/bower_components/parallax.js/parallax.min',
'slick': '/bower_components/slick-carousel/slick/slick.min',
'domReady': '/bower_components/requirejs/domReady',
//Controllers
'HomeController': 'Components/Home/home.controller',
},
shim: {
angular: {
exports: "angular",
},
'angular-route': ['angular'],
'angularAMD': ['angular'],
'angular-slick': ['angular', 'slick'],
'angular-sanitize': ['angular'],
'materialize': ['jquery', 'jquery-hammer', 'hammerjs'],
'parallax': ['jquery'],
},
baseUrl: "src",
deps: ['app']
});
app.js
define(['angularAMD', 'angular-route', 'angular-sanitize', 'angular-slick'], function(angularAMD) {
var app = angular.module("app", ['ngRoute', 'ngSanitize', 'slick']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider.when("/", angularAMD.route({
templateUrl: 'views/Home/home.html',
controller: 'HomeController',
controllerAs: 'vm'
}));
$locationProvider.html5Mode(true);
});
return angularAMD.bootstrap(app);
});
I've tried various approaches to resolve this issue, but so far none of them seem to be effective. What could I potentially be doing wrong?
Note: This error only occurs occasionally during page load.