Indigosoft / ngxd

✨🦊 NgComponentOutlet + Data-Binding + Full Lifecycle = NgxComponentOutlet for Angular 7, 8, 9, 10, 11, 12, 13, 14, 15, 16+
MIT License
321 stars 29 forks source link

Dynamically loaded component does not get updated on context change #20

Closed ciukstar closed 5 years ago

ciukstar commented 5 years ago

When the context ctx gets updated, the underlying component, defined by components.get(tmpl['component'])['component'] does not get updated (its ngOnChanges does not get called).

Everything works fine on first load. What should I do in order to get changes propagated downward?

Here is the component definition:

@Component({
  selector: 'app-layout-three-host-component',
  template: `
<ng-container
  *ngxComponentOutlet="components.get(tmpl['component'])['component']; context: ctx;">
</ng-container>
`
})
export class LayoutThreeHostComponent implements OnChanges {

  @Input() tmpl: ChartTemplate;
  @Input() ctx: any;
  @Input() components: Map<string, { component: Type<any>; context: (x: ChartTemplate) => Observable<any> }>;

  ngOnChanges(changes: SimpleChanges) {
    console.log('LayoutThreeHostComponent: changes: ', changes);
  }
}

Thanks!

thekiba commented 5 years ago

Hello, thanks for issue!

Seems interesting. Can you try to repeat that problem on stackblitz and put the link here?

ciukstar commented 5 years ago

Sorry. It seems to be a change detection issue (deep change). I have changes in a deep json structure. I expected that the reassignment itself would trigger the rebounding of the context params.