herodevs/herodevs-packages

Params in - out to the lazy load component

arangelp opened this issue · 3 comments

@aaronfrost How can we pass variables and events in out to the lazy load component?

@input() etc...

AE1NS commented

The hero-loader uses this https://github.com/herodevs/herodevs-packages/tree/master/projects/dynamic-service under the hood. So you can pass data into the component with the (init) callback of the hero-loader and call componentRef.next({YOUTDATA}); to pass the data.

@AE1NS Could you provide a small example of this? I'm a bit newbie to all that stuff and I cannot figure where to actually call .next({some data}) also what types are the passed parameters of the init callback? a ComponentRef or a ICreatedComponentInterface ?

Edit : got it working with @input... still no successs with @output

I wish there were a clear code example somewhere to look at for using hero-loader with @output parameter that gets changed and see the changes be reflected in the lazy-loaded component.

AE1NS commented

You should uninstall hero-loader and use this one, so you have more control inside your code + you dont need the lazyModules inside your angular.json anymore:
#26 (comment)