Best way to include controllers in each html?


#1

Hi there,

I’m starting with Ionic and it looks great. I have a little previous experience with Angularjs and I want to improve my skills.

One thing I want to do is to implement the Folders-by-Feature Structure. Let’s suppose that I have n features with their controllers.


First, in my app.js, I define the main module (the one that do ng-app) with the dependencies: n modules:


I also have the folders for each features, where you can find the *.controller.js, .html and so on:


In the index.html I have something like this:

<script src="app/feature1/featureone.controller.js"></script>
...
<script src="app/feature1/featureN.controller.js"></script>


  • Do I have to include the n features controllers in the index.html? (That would be a bit nasty :stuck_out_tongue_closed_eyes:)
  • Is there a way to only include the *.controller.js in the .html that needs it? I’m not talking about using multiple controllers in one html.

I’m a bit confused with this and SPA and maybe I’m misunderstanding some concepts.

Thanks!


#2

The John Papa Angularjs styleguide is a great resource for styling your ionic applications file structure. I use it in all my Ionic/Angular projects


#3

I’m going to check it out, thanks!