I was curious if anybody was familiar with separating routes from the main app config function. My route list is getting quite large and I wanted to move them into a separate file and load them into the main config. I have seen this done before but I cannot remember or find where I saw it. Any help would be appreciated.
相关问题
- angularJS: ui-router equivalent to $location.searc
- Separate AngularJS Controllers Into Separate Files
- Angular ngAnimate not working first time on page l
- Ionic Spinner not showing up
- Upload file to Google Cloud Storage using AngularJ
相关文章
- Passing variable through URL with angular js
- Watch entire object (deep watch) with AngularJS
- Angular ng-if change span text
- Can ng-show directive be used with a delay
- AngularJS $routeParams vs $stateParams
- Multiple parameters in AngularJS $resource GET
- How to set class/style of accordion heading in Ang
- PUT to S3 with presigned url gives 403 error
It's easy to set up config file separately. There are few other ways to set this up, and I played around with those structure for config; this seems to work for me the best. Enjoy!
---> myApp.html
----> app.js
--->controller.js
You can (and should !) use AngularJS modules to separate your application into modules.
Then, each module can define its own routes (with its own
.config
). Then, in your main module (usually "app"), you just need to require them as dependencies and you're set to go.Then you can have each module in its own file.
You can put your config function in a separate file easily:
App-config.js
Just make sure you include the module definition before you include App-config.js.
App-module.js