简体   繁体   English

Angular2错误导入套接字io模块

[英]Angular2 error importing socket io module

Am importing socket io module as described Here on ng-socket github page but getting an error of 我正在按照ng-socket github页面上的描述导入socket io模块,但出现错误

Unexpected value '[object Object]' imported by the module
      'AppModule'. Please add a @NgModule annotation

THis is what i have done: 这就是我所做的:

  import { SocketIoModule, SocketIoConfig } from 'ng-socket-io';

  const config: SocketIoConfig = { url: 'http://localhost:8988', options: {} };

 @NgModule({
 declarations: [
   AppComponent
],
 imports: [
     BrowserModule,
    SocketIoModule.forRoot(config) 
],
providers: [],
bootstrap: [AppComponent]
 })
export class AppModule { }

What else do i need to add, If anybody has implemented a socket io successifull with angular2 you can also advice on other better packages 我还需要添加什么,如果有人用angular2成功实现了io套接字,您还可以建议其他更好的软件包

I found a reported issue addressing this: https://github.com/bougarfaoui/ng-socket-io/issues/14 我发现了一个报告的问题来解决这个问题: https : //github.com/bougarfaoui/ng-socket-io/issues/14

  • It says upgrade to 'ngx-socket-io' for Angular4 will do - it does 它说将Angular4升级到'ngx-socket-io'是可以的-它确实
  • Maybe upgrading to 'ng2-socket-io' for Angular2 will do 也许将Angular2升级到'ng2-socket-io'会做

我认为您需要像这样导入NgModule:

import { NgModule } from '@angular/core';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM