0

I have been reading some answers and Brian Ford about how to break out my controllers into multiple files so I can keep everything a bit more organised and easy-to-find.

I am somewhat new to all of this, and just can't get my head around something.

If I create Controller1.js, Controller2.js, Controller3.js, etc, do I need to then have Script tags in my HTML file for each one e.g.:

<script src="app/js/base.js"></script>
<script src="app/js/app.js"></script>    
<script src="app/js/config.js"></script>
<script src="app/js/services.js"></script>
<script src="app/js/controller1.js"></script>
<script src="app/js/controller2.js"></script>
<script src="app/js/controller3.js"></script>

... and so on for all 57 controllers I have?

I'm building an app using a theme and it comes with an example. In it he has

<script src="app/js/base.js"></script>
<script src="app/js/app.js"></script>

at the bottom of his index.html file - and that's it. There's reference to Gulp and Grunt, but I'm not familiar with these tools. I've also stumbled into RequireJS. Head spinning about which way to go.

Any pointers or can anyone explain in a bit more dumb-ass friendly language how this is done?

Community
  • 1
  • 1
Mike Rouse
  • 1,278
  • 18
  • 34
  • 1
    requireJS is the way to go, just give it another try :p – Marcos Aug 02 '15 at 18:27
  • 1
    can use task tools like gulp or grunt to put the tags in the page for you...and later do a build process that minifies and concatenates the files for production – charlietfl Aug 02 '15 at 18:32
  • Use a bundler like browserify or webpack to create a single js file, and have just in your html. – Ori Drori Aug 02 '15 at 18:43
  • @charlietfl has it right. This when set you up well. It gives you complete control over how the files are managed for a build intended for a given environment. – tuckerjt07 Aug 03 '15 at 01:36

0 Answers0