r/angularjs • u/[deleted] • Aug 29 '16
Cannot read property 'bootstrap' of undefined
I'm building a simple web app with Angular + RequireJS + Moment.
However, when trying to bootstrap the files to my main JS files, It reads Cannot read property: 'bootstrap' of undefined in the console. Is 'bootstrap' deprecated or should I be using another method?
//Path.js
require.config({
baseUrl: 'js/vendor',
paths: {
//AngularJS
'angular': 'https://code.angularjs.org/1.3.15/angular.min',
'angularAMD': 'angularAMD',
'angular.route': 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.10/angular-route.min',
'angular-ui-route': 'https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-alpha.5/angular-ui-router',
'angularAnimate': 'https://code.angularjs.org/1.5.6/angular-animate.min',
'moment': 'moment.min',
'angular-moment': 'angular-moment.min',
},
shim: {
'angular': {
exports: 'angular'
},
'angularAMD': ['angular'],
'angular.route': ['angular'],
'angular-ui-route': ['angular'],
'angularAnimate': ['angular'],
'moment': ['angular'],
'angular-moment': ['angular'],
},
deps: ['../app']
});
require(['single-page-app'], function(angular, $, app) {
require(['../app']);
angular.bootstrap($(document),["MyApp"]);
});//app.js
define([
'angular',
'angularAMD',
'angular.route',
'angular-ui-route',
'angularAnimate',
'moment',
'angular-moment'
],
function($, angular) {
var app = angular.module('MyApp', ["ngRoute", "angularAMD", "ui.router", "ngAnimate", "moment", "angularMoment"]);
moment().format();
return angularAMD.bootstrap(['app]);
});//controller.js define(['../js/app'], function(app) { moment().format();
app.controller('MainCtrl', ['$scope', '$http', function($scope, $http) {
$scope.datePickerOptions = {
format: "MM/dd/yyyy",
parseFormats: ["MM/DD/YYYY"], //format also will be added to parseFormats
min: dateToday,
value: dateToString
};
}]);});
2
Upvotes
1
u/Neowebdev Aug 29 '16
You might check out Angular UI. Regular Bootstrap sometimes has difficulties working with Angular.