I made a service named UserEvents
@Injectable()
export class UserEvents {
public evAuthenticated: EventEmitter<string> = new EventEmitter();
public AuthUserEvent(email: string) {
this.evAuthenticated.next(email);
}
}
I included this service with the providers in AppModule
I have a service name AuthService that include the UserEvents and emits:
this.userEvents.evAuthenticated.emit(email);
And another service that suscribe
constructor(private userEvents: UserEvents){
this.userEvents.evAuthenticated.subscribe((data: string) => this.SetUser(data));
}
private SetUser(email: string) {
this.logger.info('Event triggered with ' + email);
}
But the suscription is never triggered. At list, SetUser is never called.
What is wrong here?