I have a component called NewsComponent
which is shared within my app. I would like to expand it into a NewsModule
and add a routing system to display individual articles, so that my routes would look like
/some-component
/some-component/news
/some-component/news/article/12345
/other-component
/other-component/news
/other-component/news/article/23456
To make its routes relative, I am lazy-loading the module:
const routes: Route = [
{
path: 'some-component',
component: SomeComponent
},
{
path: 'some-component/news',
component: SomeNewsWrapperComponent,
children: [
{
path: '',
loadChildren: './news/module#NewsModule'
}
]
}
// same for /other-component
]
The problem is that NewsComponent
displays visuals based on some input data, and I used to pass it via @Input
. But now that the component is encapsulated within its lazy-loaded module, this is no longer possible.
I could create a NewsService
within a third module imported both NewsModule
and AppModule
and pass data that way, but I feel that this is a breach of modularity and would like to avoid it. Is there a better solution for one-directional data flow into the module?