Reputation: 111
I have two folders inside app:
app/
├─ shared/
├─ main/
...
Each comprising their own module file.
I have imported shared module inside main module so that Shared components can be used in Main:
I have a snack-bar component inside Shared:
What I am trying to do is to take inputs from one of the Main folder components:
But then I get an error:
I am not sure where am I making mistake.
Thanks.
Upvotes: 2
Views: 991
Reputation: 111
Got the answer! Inside Shared Module file, I forgot to put SnackBarComponent inside exports array:
Thanks for the answers.
Upvotes: 1
Reputation: 8241
SnackBar
component should be declared and exported in Shared
module.
@NgModule({
// ...
declarations: [ SnackBarComponent ],
exports: [ SnackBarComponent ],
// ...
})
export class SharedModule { }
Shared
module should be imported in Main
module. (In Angular way)
@NgModule({
// ...
imports: [ SharedModule ],
// ...
})
export class MainModule { }
Upvotes: 2
Reputation: 2221
You need to add the shared
module into the main
module imports
list. it's not enough to just reference it as an import
at the top of the file. See the Angular docs: https://angular.io/guide/sharing-ngmodules
Upvotes: 1