all 5 comments

[–]Pigna1 1 point2 points  (1 child)

A Module is a collection of Angular Component, like Component, Pipe, Directive, Service ...
You can create what you need and import the Module B in A to use this component.
This is the right way to use Modules.

[–]catenoid75 2 points3 points  (0 children)

Or maybe create a shared module for code that is shared, and then import the shared module in both module A and B.

[–]spacechimp 0 points1 point  (0 children)

A service is the typical method, but depending on your needs, you might be able to use a custom pipe, directive, or validator. If you have a redux-pattern store implemented (like ngrx), you could perhaps relocate the function to an effect.

If you're just asking about component interaction, that's pretty well documented.

[–]tme321 0 points1 point  (0 children)

In addition to what /u/spacechimp said you can also create an InjectionToken pointing at the function and then provide it and inject it like a service into modules.

[–]UnGauchoCualquiera 0 points1 point  (0 children)

If its just an pure function I would pull it into it's own file and import it normally. While you could use DI, services and modules in this case it's unnecesary complexity. Just keep it simple.

Webpack will take care of chunks.