module declares component locally, but it is not exported module declares component locally, but it is not exported typescript typescript

module declares component locally, but it is not exported


You need not import AddtimeComponent in the main module. You have to export it in SharedModule like below.

import { AddtimeComponent } from './addtime/addtime.component';export { AddtimeComponent } from './addtime/addtime.component';

The export property in NgModule decorator and export in header are different. The export property in NgModule is for Angular compiler and export in header is for Typescript compiler.

If you plan to use only selector, then mention in NgModule decorator is enough. If you want to import the Typescript class in other modules, then you have to export the class in the feature module.


You do not need to import the component again, only import the SharedModule in other modules and feel free to use the component declared && exported in the SharedModule.

import { SharedModule } from '/path/to/SharedModule';@NgModule({  imports: [    ...    SharedModule  ]})

Try to replicate this setup in a Stackblitz or share access to the repository in order to allow us debug your issue and provide you a solution.

EDITED>>

Since you are trying to bootstrap the Component in the build process of your Module. Then it is possible that you need to use the EntryComponent to make the component itself to be provideed from bootstrap of the module loaded.

See it in code:

import { SharedModule } from '/path/to/SharedModule';import { AddtimeComponent } from '/path/to/AddtimeComponent';@NgModule({  imports: [    ...    SharedModule  ], entryComponents: [    AddtimeComponent  ]})

For more information, checkout: https://codinglatte.com/posts/angular/entry-components-angular/