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
  • 4,053
  • 3
  • 31
  • 62

1 Answers1

3

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
  • 89
  • 6