I was going through the Angular Tour Of Heroes tutorial and I just got to the router section. I was confused as to why they do this:
app-routing.module.ts file:
@NgModule({
//Exporting the routermodule allows router directives available to AppModule components
//This initialized the routermodule with routes so available through
exports : [RouterModule],
imports : [RouterModule.forRoot(routes)]
})
What does the export really do? I noticed that had I not created this module and done this all in "app.module.ts" file, all I would need to do is add RouterModule.forRoot(routes) to the import. I don't even need to import RouterModule.
What I don't understand is if the app.module.ts is going to import app-routing.module.ts file which will import RouterModule.forRoot(routes), why does the module still need to export RouterModule? Shouldn't RouterModule.forRoot(routes) provide the directives?
Sorry this may be confusing but I just couldn't understand the significance of the export.