0

How can we switch more than one component to another component? I need to use the "two way data binding".

I tried the following way:

<app-drawer-menu [popup]="getPopupInstance" [appHeader]="getAppHeaderInstance"></app-drawer-menu>


 export class DrawerMenuComponent implements OnInit {


    @Input() private popup: DialogLoginSignupComponent;
    @Input() private appHeader: AppHeaderComponent;

    ....

I need to go to the "DrawerMenuComponent" component "DialogLoginSignupComponent" and "AppHeaderComponent"

this does not work. Where am I wrong?

thx!

Maurizio Rizzo
  • 561
  • 2
  • 6
  • 11

1 Answers1

0

If you want to do so, You'll have to use a Service and pass the component class name to use to your child component. Then, use the ComponentFactoryResolver to create the component like this :

let factory = this.cfr.resolveComponentFactory(MyComponent);
this.cmp = this.modalBody.createComponent(factory);

If you want more details, please looks the file modal.component.ts here : Github link

Mattew Eon
  • 1,722
  • 1
  • 21
  • 38