Routing Angular Applications: Lesson 13 of 23

About Module

Up Next

Child Routes

Autoplaying in 7 seconds!

Cancel

W

Table of Contents

    e're going to refactor our entire about section to be it's own Angular NgModule.

    The reason we do this is because we can lazy-load that entire section and only load it when our users want access to it. This keeps our app lean for our users.

    app/about/about.module.ts

    import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { AboutComponent } from './about.component';
    import { AboutUserComponent } from './about-user.component';
    import { UserService } from '../shared/services/user.service';
    import { aboutRouting } from './about.routing';
    
    @NgModule({
      imports: [
        CommonModule,
        aboutRouting
      ],
      declarations: [
        AboutComponent,
        AboutUserComponent
      ],
      providers: [
        UserService
      ]
    })
    export class AboutModule {}

    Chris Sevilleja

    176 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.