0

Am importing socket io module as described Here on ng-socket github page but getting an error of

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

2 Answers 2

1

I found a reported issue addressing this: https://github.com/bougarfaoui/ng-socket-io/issues/14

  • It says upgrade to 'ngx-socket-io' for Angular4 will do - it does
  • Maybe upgrading to 'ng2-socket-io' for Angular2 will do
Sign up to request clarification or add additional context in comments.

Comments

0

I think you need to import NgModule like this:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.