When importing modules in app.module.ts
, the process involves adding a specific entry, as seen below:
@NgModule({
declarations: [
AppComponent,
HomeComponent,
DirectoryComponent,
FilterPipe,
LoggingService
],
imports: [
FormsModule,
BrowserModule,
HttpClientModule,
routing
],
providers: [],
bootstrap: [AppComponent]
})
However, the RouterModule
module is directly utilized in ../src/app/app.routes.ts
, demonstrated by the code snippet below:
import {Routes, RouterModule} from "@angular/router";
export const routes:Routes = [
/* Each route will be an object {}*/
{path: 'directory', component: DirectoryComponent},
{path: '', component: HomeComponent}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
It's worth noting that there is no mention of RouterModule
within the @NgModule(imports: [..])
section.
1) What are the various methods for importing an Angular module?
2) How does the import of an Angular module differ from the import of a TypeScript module?