5

I have MyService which is injected into ComponetA and ComponetB.

Is it possible to find out from which component is the MyService.myMethod() called?

@Injectable()
export class MyService {

  public myMethod(): void {
    console.log('called from component: ' + component);
  }
}
Tomas Marik
  • 3,933
  • 3
  • 26
  • 58

1 Answers1

2

Only solution would be to use a parameter which would be passed to the called function.

EDIT: Previous suggestion to refer here would not work because it only works without strict mode.

Community
  • 1
  • 1
Mantas
  • 79
  • 6