0

I am implementing a sample from the instruction of Dan Wahlin. I encountered same problem as this guy, I have tried his solution and investigated through my source code but there is not any redefinition of the module.

Here is my code

// main.js

require.config({
    baseUrl: '/app/',
    urlArgs: 'v=1.0'
});

require(
    [
        'config/myapp',
        ..... [dependencies]
    ],
    function () {
        angular.bootstrap(document, ['myApp']);
    });

// myapp.js

'use strict';

define(['services/routeResolver'], function () {

var app = angular.module('myApp', ['ngRoute', 'ngAnimate', 'routeResolverServices', 'ui.bootstrap', 'breeze.angular']);

console.log('A'); //working
app.config(['$routeProvider', function($routeProvider){

    console.log('C'); // this line does not work
}]);
console.log('B'); //working
app.run(['$rootScope',
    function ($rootScope) {

    }]);

return app;

});

I can do console.log to print 'A', 'B'; but 'C' is not printed out, it is indicating that the function inside .config does not work.

Any help is highly appreciated. Thank you!

Community
  • 1
  • 1
Telvin Nguyen
  • 3,569
  • 4
  • 25
  • 39
  • Do you get any console errors ? – Jayantha Lal Sirisena Apr 02 '15 at 03:23
  • @JayanthaLalSirisena I don't get the error for now, but this is the cause that make my app works incorrectly. Inside the .config, I have to initialize a variable such as app.register = {...} but it never be set because of the mentioned problem, it would throw error about undefined value after then. The console.log('C') should have to run while it didn't – Telvin Nguyen Apr 02 '15 at 03:27
  • Did you check your code calls to `angular.bootstrap(document, ['myApp']);` line ? – Jayantha Lal Sirisena Apr 02 '15 at 03:41
  • There are 4 months passed. I quit from RequireJs and moved to https://oclazyload.readme.io/ instead. It is more stable and flexible. I have used it on my project with multiple different configuration and it works pretty well. I do not have the answer for this question as well. But if someone else want to find another way not RequireJs, could refer to the mentioned option. – Telvin Nguyen Sep 15 '15 at 03:56

0 Answers0