Skip to content

Commit

Permalink
conf lazy load files module
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudard committed Feb 24, 2020
1 parent 9576759 commit c8aaea6
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 67 deletions.
15 changes: 0 additions & 15 deletions src/angular/src/app/admin/admin.component.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/angular/src/app/admin/admin.module.spec.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/angular/src/app/admin/admin.module.ts

This file was deleted.

21 changes: 12 additions & 9 deletions src/angular/src/app/app-routing/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ import { TodoEditComponent } from '../todo/todo-edit/todo-edit.component';

const routes: Routes = [
{
path: '',
redirectTo: 'todopage',
pathMatch: 'full'
},
{
path: 'adminpage',
loadChildren: () => import('../admin/admin.module').then(m => m.AdminModule),
path: 'files',
loadChildren: () => import('../files/files.module').then(m => m.FilesModule)
},
{
path: 'todopage',
component: TodoComponent
},
{ path: 'todopage/:id', component: TodoEditComponent },
{ path: '**', redirectTo: 'todopage' } // bad routes redirect to todopage
{
path: 'todopage/:id',
component: TodoEditComponent
},
{
path: '',
redirectTo: 'todopage',
pathMatch: 'full'
},
{ path: '**', redirectTo: 'todopage' }
];

@NgModule({
Expand Down
2 changes: 0 additions & 2 deletions src/angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CompModule } from './comp/comp.module';
import { ToastrModule } from 'ngx-toastr';
import { TodoModule } from './todo/todo.module';
import { AppRoutingModule } from './app-routing/app-routing.module';
import { AdminModule } from './admin/admin.module';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { CustomDateParser } from './shared/custom-date-parser';

Expand All @@ -22,7 +21,6 @@ import { CustomDateParser } from './shared/custom-date-parser';
imports: [
CompModule,
TodoModule,
AdminModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
Expand Down
2 changes: 1 addition & 1 deletion src/angular/src/app/comp/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a class="nav-link" [routerLinkActive]="['active']" routerLink="todopage">Todo</a>
</li>
<li class="nav-item">
<a class="nav-link" [routerLinkActive]="['active']" routerLink="adminpage">Admin</a>
<a class="nav-link" [routerLinkActive]="['active']" routerLink="files">Files</a>
</li>
</ul>
<div class="float-right pr-3">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AdminComponent } from './admin.component';

const routes: Routes = [
{
path: '',
component: AdminComponent
}
];
import { FilesComponent } from './files.component';

const routes: Routes = [{ path: '', component: FilesComponent }];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AdminRoutingModule {}
export class FilesRoutingModule { }
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { AdminComponent } from './admin.component';
import { FilesComponent } from './files.component';

describe('AdminComponent', () => {
let component: AdminComponent;
let fixture: ComponentFixture<AdminComponent>;
describe('FilesComponent', () => {
let component: FilesComponent;
let fixture: ComponentFixture<FilesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminComponent ]
declarations: [ FilesComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AdminComponent);
fixture = TestBed.createComponent(FilesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
15 changes: 15 additions & 0 deletions src/angular/src/app/files/files.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-files',
templateUrl: './files.component.html',
styleUrls: ['./files.component.scss']
})
export class FilesComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
20 changes: 20 additions & 0 deletions src/angular/src/app/files/files.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { FilesRoutingModule } from './files-routing.module';
import { FilesComponent } from './files.component';
import { UploadComponent } from './upload/upload.component';
import { ReactiveFormsModule } from '@angular/forms';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';


@NgModule({
declarations: [FilesComponent, UploadComponent],
imports: [
CommonModule,
ReactiveFormsModule,
FontAwesomeModule,
FilesRoutingModule
]
})
export class FilesModule { }

0 comments on commit c8aaea6

Please sign in to comment.