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();
});
我正在嘗試在 socket.io 類中呼叫通知服務,但無法正常作業。
uj5u.com熱心網友回復:
將普通功能更改為箭頭功能,以訪問此當前范圍之外的內容。
ngOnInit() {
socket.on("laravel_database_chat:test", (message) => {
this.notifyService.showSuccess();
});
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/462589.html
標籤:javascript 有角度的 打字稿 插座
