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.

3
  • 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. Commented Sep 27, 2016 at 17:22
  • stackoverflow.com/questions/15939913/… Commented Sep 27, 2016 at 17:23
  • ok so Angular doesn't provide an out-of-the-box way of managing these files...thanks Commented Sep 27, 2016 at 17:33

1 Answer 1

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.

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

Comments

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.