3

I used the angular seed (with the file index-async.html(dependencies loaded asynchronously)) in order to start my web project, but my controllers would need some reorganisation. I have now 3 files full of controllers (700+ lines). Is there an elegant way to load my controllers if I reorganize them in 10 files (and more in the future).

Also, more files means less merging conflicts (Yeah!!!)

Thx in advance

1 Answer 1

5

I make extensive use of the angular.module().controller() syntax to group my controllers by module, which has greatly improved the organization of my angular code. As an added benefit, your controllers are no longer globally name-spaced functions.

You can read more in the Module API documentation.

Sign up to request clarification or add additional context in comments.

3 Comments

@cricardol During development I do manually added each .js file (each of which contain one angular module) to my index.html page. Concatenating these files into one file can easily be included in a build process, however.
You can also add a static reference to a js file during development. This static file gets automatically updated through projects like LiveReload or Grunt.js which concatenates files upon file changes.
link you added just pints to angular docs where thee is no real example of what you described.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.