I have simple module SomeOtherModule and i want that it's CounterComponent is available as path in AppModule.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CounterService } from '../services/counter.service';
import { CounterComponent } from '../counter/counter.component';
@NgModule({
imports: [ CommonModule],
providers: [CounterService],
declarations: [ CounterComponent ],
exports: [CounterComponent]
})
export class SomeOtherModule { }
and AppModule:
import { SomeOtherModule } from './some-other/some-other.module';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
CounterComponent,
],
imports: [SomeOtherModule,
RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: 'counter', component: CounterComponent },
]
)]
TS error on CounterComponent not found
SomeOtherRoutingModulean then redirect 'counter' to theSomeOtherModulefrom theAppModule.