Skip to content Skip to sidebar Skip to footer

Angular2 - Call A Function From Another Standalone Component. Basically, Call Function From Outside Component

I'm loading in a component (Component1) another standalone component(Component2) that contains a form. Imagine you have made a form component and I want to integrate it in my compo

Solution 1:

Without much context, I think you need a service to do this. If there's no relation between those 2 components, why would you call a function from component 2? Put save logic into a service and inject it on whatever component you need it.

Solution 2:

This is about the component interaction, you need to use service for communicating between two different components. Main thing is the dependency injection of Angular.

Simply you can use Subject.

Post a Comment for "Angular2 - Call A Function From Another Standalone Component. Basically, Call Function From Outside Component"