I'm trying to execute a function from another component (These 2 components are NOT siblings). My guess is that I will need to use @Output and eventEmitter to accomplish this or create a Service and subscribe to the Observable to share the same data throughout all the components (I know how to pass a message( string) but I don't know how to execute a function). I'm not really sure where to start. I'm trying to execute function1 FROM function2. Can anyone help me on how to get this to work? Please provide a plunker. This is what my project looks like:
src
|__app(FOLDER)
|__home(FOLDER)
| |
| |__home.component.ts
| |______function2(){
| What do I need to put in here to execute function1?
| }
|
|__products(FOLDER)
|
|__tools(FOLDER)
|
|____tools.component.ts
|____function1(){
alert("I'm inside function 1!!");
}
As you saw I have a file home.component.ts that has function2 and a file tools.component.ts that has function1, so any ideas how to execute function1 from function2 ?