Created
June 17, 2021 07:47
-
-
Save yngvebn/cf19144b7991629ddc50abbb44372c35 to your computer and use it in GitHub Desktop.
Story with module and nested components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'my-child', | |
template: `<span>I'm the child!</span>`, | |
styles: [] | |
}) | |
export clsas MyChildComponent {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
declarations: [MyChildComponent], | |
exports: [MyChildComponent], | |
imports: [CommonModule] | |
}) | |
export class MyChildModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'my-parent', | |
template: '<my-child></my-child>', | |
styles: [] | |
}) | |
export clsas MyParentComponent {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
declarations: [MyParentComponent], | |
exports: [MyParentComponent], | |
imports: [CommonModule, MyChildModule] // <- Important part. Parent imports Child module | |
}) | |
export class MyChildModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
title: 'My Parent Component', | |
component: MyParentComponent, | |
decorators: [ | |
moduleMetadata({ | |
imports: [MyParentModule] | |
}) | |
] | |
} | |
export const Default = (props) => ({ props }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment