Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.js: move app.config() into a config.js file. #155

Open
dave-k opened this issue Sep 4, 2015 · 4 comments
Open

app.js: move app.config() into a config.js file. #155

dave-k opened this issue Sep 4, 2015 · 4 comments

Comments

@dave-k
Copy link

dave-k commented Sep 4, 2015

I have an AngularAMD application as described here http://marcoslin.github.io/angularAMD/#/home

Can the app.config( ) { ... } section of code be moved from app.js into a config.js file?
Where is the new config.js file loaded?

app.js

define(['angularAMD', 'angular-route'], function (angularAMD) {
    var app = angular.module("webapp", ['ngRoute']);
    app.config(function ($routeProvider) {
        $routeProvider.when("/home", angularAMD.route({
            templateUrl: 'views/home.html', controller: 'HomeCtrl',
            controllerUrl: 'ctrl/home'
        }))
    });
    return angularAMD.bootstrap(app);
});
@F1LT3R
Copy link

F1LT3R commented Nov 24, 2015

+1, have several large config files and would love the ability to load config outside of the app file.

@ivosantiago
Copy link

Seems like this project is discontinued... Any thoughts about this issue @marcoslin ?

@F1LT3R
Copy link

F1LT3R commented Mar 22, 2016

It seems like a lot at first to try doing what this plugin is doing, but it's not too bad if you take small steps and commit to the process.

I got frustrated with it because there always seemed to be JavaScript load errors when I tried using this library. I could never work out if it was me just doing it wrong (probably) or if it was something in the library that was not quite right.

So I ended up starting from with require-js and angular ui-router scratch with these ideas and came up with something usable, maybe it will help:

Basic demo: http://plnkr.co/edit/XU7MIXGAnU3kd6CITWE7?p=info
More complete template: https://github.com/F1LT3R/angular-require-lazyload-template

Dan Wahlin's post is pretty helpful: http://weblogs.asp.net/dwahlin/dynamically-loading-controllers-and-views-with-angularjs-and-requirejs

@marcoslin
Copy link
Owner

Sorry guys... The day job is killing me and leaving me no time to address my side projects. The quick answer to the question is that yes, you can move the config to a config.js file but the current implementation will only allow this to be done after bootstrap.

Take a look at the example here: https://plnkr.co/edit/G4pII6?p=preview

Basically, app.js defines the home state and page2 state is defined in config.js which is only called when home_ctrl is loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants