Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using next(...) to set @inputs and @outputs on hero-loader components does not work for @output callbacks #27

Open
boltex opened this issue Nov 12, 2020 · 1 comment

Comments

@boltex
Copy link

boltex commented Nov 12, 2020

Works fine with @inputs, the .next method for an @input member works fine, but also providing callback functions for @output does nothing.

in lazy-loaded component:

  @Input()
  public myInput: any; 

  @Output()
  public myOutput: EventEmitter<void> = new EventEmitter();

in outer program itself :

public initMyComponent(p_componentRef: ICreatedComponentInterface): void {
    p_componentRef.next({
      myInput: this.someinfo,
      myOutput: function(): void {
        console.log('hello'); // does not work
      }
    });
}
@kmittapelly
Copy link

kmittapelly commented Dec 16, 2020

<hero-loader *ngIf="load" moduleName="src/app/first/first.module#FirstModule" (init)="onLazyInit($event)"></hero-loader>

  public onLazyInit(ref: any) {
    let num = 0;
    setInterval(() => {
      ref.next({ myInput: num++ }); // this will change the input passing into the lazy loaded component
    }, 1000);

    // this will subscribe to the output events emitted from the lazy loaded component
    ref.componentRef.instance['myOutput'].subscribe((val: number) => {
      console.log('inside subscribe', val);
    })
  }

@boltex Subscribing to the events on the event emitter variable from the lazy-loaded component instance worked for me. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants