1

I am new to Angular and making a small project.

For now, I have one large App.js where I define my route config and controllers and such.

In my index.html file, I link to this script file and everything works fine, I have multiple views and a small working app.

Now I would like to extract the controllers from my big javascript file, but then, what is the best way to include all those files? I do not want to have one script tag per file.

Bruno
  • 4,685
  • 7
  • 54
  • 105
  • That's exactly what you should have. Then you should use a build tool, like browserify or closure compiler, to put them back into a single file before deploying. – zero298 Sep 27 '16 at 17:22
  • http://stackoverflow.com/questions/15939913/single-page-application-load-js-file-dynamically-based-on-partial-view – Sajeetharan Sep 27 '16 at 17:23
  • ok so Angular doesn't provide an out-of-the-box way of managing these files...thanks – Bruno Sep 27 '16 at 17:33

1 Answers1

2

If you are worried about the fact that you will add the files manually over and over again, you could try to automate this process using Gulp or Grunt but it will take a bit of research. What I recommend, though, is using an already set-up generator with these systems in place for you. Such a generator would be the Hottowel generator made by John Papa, which also respect his Angular Styleguide.

Whatever you choose in the end is your preference, but I recommend looking into such generators and explore their way of doing the architecture of an Angular application and then see what suits your needs best.

Peter_Fretter
  • 1,135
  • 12
  • 20