3

I have just started learning angular.js with .NET MVC, but the major problem that I'm thinking is that in all tutorials people end up referencing 10 controllers and 10 services in the main(_Layout) page which basically looks bad.

Now I know this must sound dumb but I've tried to reference the specific controller / service in its specific page but then angular won't work(for some stupid reason). To mention scripts are loaded, they just dont work!.

Would I end up in minifying all the controllers/services in 1 big file and reference it in the Layout page or is it another way to do it?

2
  • If you use .NET MVC 4/5 you can use Bundle for this purpose. read this article : asp.net/mvc/overview/performance/bundling-and-minification Commented Apr 26, 2015 at 14:42
  • 1
    You can use Grunt or Gulp to combine all the js file into one big minified file. Another option will be to do lazy loading of these components Commented Apr 26, 2015 at 14:49

1 Answer 1

3

Typical approaches:

  • Your main page (e.g., index.html) pulls in all your Angular JavaScript files with individual <script> tags. Thus, all definitions are available to the entire application. In most single page web applications, you're only going to have one main page anyway; the rest of your content comes in as needed (e.g., dropped into an ng-view element via the router).
  • You use some kind of back-end build process (e.g., a Gulp task) to combine all your separate JavaScript files into one JavaScript file (minified or not); you then pull that file in.
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.