alexabbott / firebase-cms

A CMS + E-commerce platform built with Angular and Firebase
https://fir-cms-76f54.firebaseapp.com/
MIT License
313 stars 125 forks source link

Decoupling admin routes and creating shared modules #6

Closed ankemp closed 7 years ago

ankemp commented 7 years ago
alexabbott commented 7 years ago

@ankemp This one is causing a few problems, so I'm not merging it yet. The OrdersModule isn't working on the admin side and I'm not able to generate new components using ng cli because it's confused which module to put the new stuff into

ankemp commented 7 years ago

You mean the orders component?

As for the angular CLI, it's not confused, you just need to specify what module the component should be placed into.

The modules should actually be broken out even more, and the root app.module shouldn't include any components except for the app.component.

For example:

app.module:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { environment } from '../environments/environment';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

// Services
import { NavigatorRefService } from './services/navigator-ref.service';
import { WindowRefService } from './services/window-ref.service';
import { UserService } from './services/user.service';

@NgModule({
  imports: [
    BrowserModule,
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireDatabaseModule,
    AngularFireAuthModule,
  ],
  declarations: [
    AppComponent,
  ],
  providers: [NavigatorRefService, WindowRefService, UserService],
  bootstrap: [AppComponent]
})
export class AppModule { }

app-routing:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
  { path: '', loadChildren: 'app/scanner/scanner.module#ScannerModule' },
  { path: 'user', loadChildren: 'app/user/user.module#UserModule' },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
ankemp commented 7 years ago

Closing, will work on a new PR one day. Maybe do it as smaller steps