Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs : Code organisation of controllers

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

like image 264
cricardol Avatar asked Dec 06 '25 09:12

cricardol


1 Answers

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.

like image 185
Noah Freitas Avatar answered Dec 08 '25 01:12

Noah Freitas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!