So we’ve covered how to setup basic routing between components in Angular 7 Routing: The Basics but what if we have a module with routes? Routing is handled pretty much the same except for one piece. We’ll be using the RouterModule.forChild() method to inject our routes instead of RouterModule.forRoot(..).

module-routes.module.ts

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentAComponent} from './component-a/component-a.component';
import {ComponentBComponent} from './component-b/component-b.component';
import {RouterModule} from '@angular/router';

@NgModule({
    imports: [
        
        CommonModule,

        RouterModule.forChild([

            {

                path: 'component-a',
                component: ComponentAComponent

            }, {

                path: 'component-b',
                component: ComponentBComponent

            }
        ])
    ],
    declarations: [ComponentAComponent, ComponentBComponent]
})
export class ModuleRoutesModule {
}

Source Code