【发布时间】:2019-12-10 00:30:19
【问题描述】:
我尝试使用 ngx-socket-io iPackage s 在 anguler JS 中不起作用
https://www.npmjs.com/package/ngx-socket-io 示例但不起作用。
如果有其他要在 Angular js 中使用的包,请告诉任何人。
npm install ngx-socket-io
Moddule.js
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
const config: SocketIoConfig = { url: 'http://localhost:8988', options: {} };
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
SocketIoModule.forRoot(config)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
ChatService.js
import { Injectable } from '@angular/core
import { Socket } from 'ngx-socket-io'
@Injectable()
export class ChatService {
constructor(private socket: Socket) { }
assign_biker(biker_id){
this.socket.emit("assign_biker_order",{'biker_id:biker_id })
}
}
【问题讨论】:
标签: node.js angularjs sockets websocket socket.io