Skip to content

Instantly share code, notes, and snippets.

@yngvebn
Created June 17, 2021 07:47
Show Gist options
  • Save yngvebn/cf19144b7991629ddc50abbb44372c35 to your computer and use it in GitHub Desktop.
Save yngvebn/cf19144b7991629ddc50abbb44372c35 to your computer and use it in GitHub Desktop.
Story with module and nested components
@Component({
selector: 'my-child',
template: `<span>I'm the child!</span>`,
styles: []
})
export clsas MyChildComponent {}
@NgModule({
declarations: [MyChildComponent],
exports: [MyChildComponent],
imports: [CommonModule]
})
export class MyChildModule { }
@Component({
selector: 'my-parent',
template: '<my-child></my-child>',
styles: []
})
export clsas MyParentComponent {}
@NgModule({
declarations: [MyParentComponent],
exports: [MyParentComponent],
imports: [CommonModule, MyChildModule] // <- Important part. Parent imports Child module
})
export class MyChildModule { }
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