【发布时间】:2018-04-22 05:29:04
【问题描述】:
这是我的代码。我们如何在 Angular 中使用 socket.io?
import { Component } from '@angular/core';
import { createServer, Server } from 'http';
import * as express from 'express';
import * as socketIo from 'socket.io';
const SERVER_URL = 'localhost:4200';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public static readonly PORT:number = 8080;
private app: express.Application;
private server: Server;
**"private io: SocketIO.server;"** ////at this line i get error that cannot find namespace SocketIO
private port: string | number;
}
我正在尝试在我的 Angular 应用程序中使用 socket.io。我在粗线处得到了错误。谁能帮我解释一下为什么会出现这个错误?
【问题讨论】:
-
这与 Angular 无关。如果您使用的是 TypeScript,请阅读有关 TypeScript 的信息