generator-cg-angular icon indicating copy to clipboard operation
generator-cg-angular copied to clipboard

No .html file when creating a module

Open corneadoug opened this issue 9 years ago • 2 comments

I find it pretty strange for a 'module' not to have it's own .html file. You will obviously cut your module into multiple partials, but you still need to define the ui-view or ng-include for your partials. (What better place than the module .html?)

corneadoug avatar Mar 11 '15 14:03 corneadoug

I have no idea what sense it would make to have a random html file created when you create a module. If you want a partial, create one in the module...? Why would you declare a ui-view in a module? Wouldn't that go in the main app (likely the index.html)?

cgross avatar Mar 14 '15 22:03 cgross

Maybe I wasn't concise enough,

When you create your angular app, you will have your app module in app.js, and your index.html file.

From the angular Module Documentation: 'Most applications have a main method that instantiates and wires together the different parts of the application.'

I think that it should not only apply to .js files, just like index.html is linking other partials of the app module, then having a .html file in a module would link its own partials.

For big applications, especially those needing ui-router, you will start breaking your application modules base on your main 'pages'.

For example, if you visit mywebsite.com/admin, you would see your admin page, which is composed of multiple partials which are all connected together in admin.html.

admin.html

<div>
  <div ng-include="admin-partial1/admin-partial1.html"></div>
  <div ng-include="admin-partial2/admin-partial2.html"></div>
  <div ng-include="adming-partial3/admin-partial3.html"></div>
</div>

In the current module configuration, we need to create a first partial to do the job of admin.html (admin-partial), then create all the other partials into admin-partial if we want to respect some kind of logical directory structure. Which in the end is not super elegant.

Maybe it is only a personal choice, juste like the fact that I like having a main controller in a module (and I can simply add it inside app.js or my_module.js).

I can of course just create by hand that .html file, I just thought it could make sense to have it directly in the generator.

corneadoug avatar Mar 15 '15 01:03 corneadoug