marcoslin / angularAMD

Facilitate use of RequireJS in AngularJS
http://marcoslin.github.io/angularAMD
MIT License
734 stars 171 forks source link

Cannot Get App to Init #167

Open stljeff1 opened 8 years ago

stljeff1 commented 8 years ago

Hi,

First, thanks for making this utility.

I have been unable to get my app to initialize after converting my app to utilize AngularAMD. I have no idea why its not working, and therefore, have no where to begin troubleshooting.

Essentially, my app.js file is loaded and parsed, but execution never happens

Here is my main.js require.config({

baseUrl: "js/",

// alias libraries paths
paths: {
    'jquery': 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min',
    'bootstrap': 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min',
    'angular': 'https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular',
    'angular-route': 'https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular-route.min',
    'angularAMD': 'angularAMD'        
},

// Add angular modules that does not support AMD out of the box, put it in a shim
shim: {
      'angularAMD': ['angular'],
    'angular-route': ['angular'],
    'bootstrap': ['jquery']
},

// kick start application
deps: ['app']

});

Here is my app.js: define(['angularAMD', 'angular-route', 'controllers/ctrlOne', 'controllers/ctrlTwo'], function(angularAMD) { 'use strict'; var app = angular.module('MyApp', ['ngRoute']); console.log(app); // yada yad yada });

Can you tell me why that console.log() call never fires? I am using Firebug to set breakpoints where the yada yada yada comment is, but none of the code in the block executes. Can you see anything that I'm doing wrong?

the-unsoul commented 8 years ago

@stljeff1 is that all of the content of your app.js ? If yes then you will need something like.

// config your app
app.config(/* your config goes here... */);

// code...

// bootstrap with angularAMD and return an object, so requireJS/angularAMD can use it later
return angularAMD.bootstrap(app);

Also I can see that you are calling angular in your app.js without define the alias in define() block or config global alias in shim