export class AppComponent { title = 'my-app'; constructor(private notifyService : NotificationService) {} ngOnInit() { socket.on("laravel_database_chat:test", function(message){ //I WANT TO CALL NOTIFICATION SERVICE HERE, BUT NOT WORKING this.notifyService.showSuccess(); });Estoy tratando de llamar al servicio de notificación dentro de la clase socket.io, pero no funciona.
Cambie la función normal a la función de flecha para obtener acceso a este ámbito actual fuera.
ngOnInit() { socket.on("laravel_database_chat:test", (message) => { this.notifyService.showSuccess(); }); }