刘喜泰
刘喜泰

Reputation: 11

Can I configure AngularJS ui-router in other js files and not only in app.js(defalut)

I now, use angularJS, requireJS, bootstrap to structure my project.Just like the title.Because of all router configured in app.js can make this file be so large and difficult to maintain in the future.So is existing some solution to solve it?Thanks.

Upvotes: 0

Views: 45

Answers (2)

Vinit Solanki
Vinit Solanki

Reputation: 2023

You can add your angularjs configuration in any .js file or you can give any name of file, but this file must be included first in html.

Upvotes: 0

Crhistian
Crhistian

Reputation: 1272

Yes, definitely. We actually have a routing config file in each section of our site. It keeps it a lot more organized.

In the JS file you want to configure it you will just need to get a reference to your angular module and chain your config file off it. This is done by simply writing our your module as you would without the dependency brackets like this:

angular.module('myApp').config('configForThisRoute',function($stateProvider){
//define your states as usual
}

Upvotes: 2

Related Questions