I'm able to import a component from another module in routing which is not being exported.
A routing module
{
path: 'home',
component: DashComponent
}
B routing module
{
declarations: [DashComponent],
}
As seen in the above code, DashComponent
is not being exported in B routing module but still I'm able to use it in A routing module without any errors. Why ?
In module A, there must be export class DashComponent
and in module B you must be directly importing the DashComponent
using import { DashComponent } from '../moduleB/dash.component'
.
Now this is a perfectly fine js export-import , so there is no error.
Second, the export property of a module(A) controls what the another module(B) will get access to, if it imports this module(A), without you having to import every other export from that module(A) separately, thus making things convenient and systematic. But it cannot stop you from importing the exports directly from other modules, like you did (but doing this ruins the whole point of using modules).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.