From ed121d347a961e0780ae365ecd1282d8aa5eb528 Mon Sep 17 00:00:00 2001 From: Jeremie BRISON <ext.sopra.jbrison@grandlyon.com> Date: Fri, 26 Feb 2021 11:49:17 +0100 Subject: [PATCH] feat(post) : init lazy loading --- src/app/app-routing.module.ts | 4 ++++ src/app/posts/posts-routing.module.ts | 11 +++++++++++ src/app/posts/posts.component.html | 1 + src/app/posts/posts.component.scss | 0 src/app/posts/posts.component.spec.ts | 25 +++++++++++++++++++++++++ src/app/posts/posts.component.ts | 15 +++++++++++++++ src/app/posts/posts.module.ts | 10 ++++++++++ 7 files changed, 66 insertions(+) create mode 100644 src/app/posts/posts-routing.module.ts create mode 100644 src/app/posts/posts.component.html create mode 100644 src/app/posts/posts.component.scss create mode 100644 src/app/posts/posts.component.spec.ts create mode 100644 src/app/posts/posts.component.ts create mode 100644 src/app/posts/posts.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 045be83e7..556fb1eff 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -87,6 +87,10 @@ const routes: Routes = [ component: FormComponent, canDeactivate: [DeactivateGuard], }, + { + path: 'posts', + loadChildren: () => import('./posts/posts.module').then((m) => m.PostsModule), + }, { path: '**', redirectTo: 'home', diff --git a/src/app/posts/posts-routing.module.ts b/src/app/posts/posts-routing.module.ts new file mode 100644 index 000000000..80b37d9e9 --- /dev/null +++ b/src/app/posts/posts-routing.module.ts @@ -0,0 +1,11 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { PostsComponent } from './posts.component'; + +const routes: Routes = [{ path: '', component: PostsComponent }]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class PostsRoutingModule {} diff --git a/src/app/posts/posts.component.html b/src/app/posts/posts.component.html new file mode 100644 index 000000000..2c30d2067 --- /dev/null +++ b/src/app/posts/posts.component.html @@ -0,0 +1 @@ +<p>posts works!</p> diff --git a/src/app/posts/posts.component.scss b/src/app/posts/posts.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/posts/posts.component.spec.ts b/src/app/posts/posts.component.spec.ts new file mode 100644 index 000000000..9702efa6e --- /dev/null +++ b/src/app/posts/posts.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PostsComponent } from './posts.component'; + +describe('PostsComponent', () => { + let component: PostsComponent; + let fixture: ComponentFixture<PostsComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PostsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PostsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/posts/posts.component.ts b/src/app/posts/posts.component.ts new file mode 100644 index 000000000..73d77fc55 --- /dev/null +++ b/src/app/posts/posts.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-posts', + templateUrl: './posts.component.html', + styleUrls: ['./posts.component.scss'] +}) +export class PostsComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/posts/posts.module.ts b/src/app/posts/posts.module.ts new file mode 100644 index 000000000..32e4a4b79 --- /dev/null +++ b/src/app/posts/posts.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { PostsComponent } from './posts.component'; +import { PostsRoutingModule } from './posts-routing.module'; + +@NgModule({ + declarations: [PostsComponent], + imports: [CommonModule, PostsRoutingModule], +}) +export class PostsModule {} -- GitLab