herodevs / herodevs-packages

This project is where HeroDevs develops our public npm packages.
55 stars 12 forks source link

Params in - out to the lazy load component #9

Open arangelp opened 4 years ago

arangelp commented 4 years ago

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

@Input() etc...

AE1NS commented 4 years ago

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.

boltex commented 3 years ago

@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 3 years ago

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: https://github.com/herodevs/herodevs-packages/issues/26#issuecomment-707169033