Inject component into another component

Asked

Viewed 49 times

0

I would like to know, if I can inject a component into another component, I have a function within a component and when I go to do something into another component, I would like to call that function the other component. I know there is an Eventemitter, but I would like to know if any mistakes can happen. Here I managed to do the function of the other component and, it is executed perfectly, but I do not know if the use of this can bring some future error. I used @Injectable() in the component I’d like to use in the other component.

  • 2

    Dude, what exactly do you want to do? it is better to use eventEmmiter, injectable should be used for services and not components pq components are visual and services are not. Maybe you’d better put that method of yours into a service and inject it into the two components.

  • 1

    put the code of what you’re trying to do.

  • So it worked out what I wanted to do. I was also thinking of using Eventemmiter with a service, but I tried injecting the component into another one and it worked. What I wanted to know is if this could bring any future problems.

  • 1

    Face is terrible this and totally not the role of a component.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.