I have been reading over the seed template for Angular 2 projects and have a question about when to have a module vs components inside a larger module. I understand it it reccommended to create modules per feature but am having a hard time coming to a decision how to structure.
I have a project, where there is a public and admin section (admin is wrapped in a guard). Each section has a few different features, but they share the same underlying models (get an item, create an item, etc). My question is, what is the best way to structure this, knowing that some components need to be guarded? Do I have an AppModule with a Public and AdminModule (guarded) underneath it (with components that reference models in a sharedmodule) and a module for each feature under there? Or do I have an AppModule with all the Feature modules underneath and guard each component directly? I imagine this question is asked a lot, or I am asking in the wrong place, so any direction on where/what to do would be appreciated.
AppModule for reference
import { NgModule, Inject } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { HttpModule, Http } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { Ng2BootstrapModule } from 'ngx-bootstrap';
import { NavMenuComponent } from './navmenu/navmenu.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { LinkService } from '../shared/link.service';
import { AuthenticationService } from './authentication.service';
import { ORIGIN_URL } from '../shared/constants/baseurl.constants';
import { TransferHttpModule } from '../../modules/transfer-http/transfer-http.module';
@NgModule({
declarations: [
NavMenuComponent,
NotFoundComponent
],
imports: [
CommonModule,
HttpModule,
FormsModule,
RouterModule,
Ng2BootstrapModule.forRoot(),
TransferHttpModule,
],
providers: [
LinkService,
AuthenticationService,
],
exports: [
CommonModule,
HttpModule,
FormsModule,
Ng2BootstrapModule,
TransferHttpModule,
RouterModule
]
})
export class CoreModule {
}