Closed alirezabahary closed 1 year ago
Hello, @alirezabahary
NgOnChanges is not invoked on the mfe component, when you change directive property "inputs", right?
ngOnChanges is called when an Input Parameter is changed from your parent component.
This lib doesn't pass inputs from mfe directive direct to your mfe-components, so if you want to do something after any detection you should use ngAfterViewChecked()
If you need pass data and some how to react t changes in this data, you can
If you need to pass data and be able to somehow react to data changes, you can do this:
myData$ = new Subject<number>();
const myInjector = Injector.create({ parent: this._injector, providers: [ { provide: 'CONTEXT/FOR_MY_COMPONENT', useValue: { data: myData$ }, }, ] });
2. Pass injector to mfeOutletDirective
```html
<ng-container *mfeOutlet="
'my-component';
module: 'MyModule';
component: 'MyComponent';
injector: myInjector;
">
</ng-container>
class MyComponent {
constructor(@Inject('CONTEXT/FOR_MY_COMPONENT') context: { data: Observable<number>} {
context.data.subscribe((data) => {
// do something
// fetch your additional data
});
}
When changing the inputs, the ngOnChanges method is not being called, and we must use a setTimeOut to delay fetching the data. Under no circumstances is the ngOnChanges method being invoked